Python Forum
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Somebody help pls!!
#1
I have a homework, which I cant do myself. It's so hard to do, and I have like three days to finish it. Aaaand I'm so sorry, I'm from Finland so my english.... is really bad. I try to translate this as good as possible. Hopefully somebody can help me :D

"Write a program, which maintains simple tasklist. The tasklist is saved to textfile "todo.txt", and every line has own tasks.
The file should look like this:
Buy milk, 3.9.2017
Code a program, 1.9.2017
Go to sleep early, 12.8.2017

For each task, the description and creation date must be saved. In file, every information is separated with commas.

internally, the program stores tasks in a dictionary that has a format:
{'number':1, 'task':'description of the task', 'date': 'dd.mm.yyyy'}

The number is similar with the task in the text file todo.txt. The number of the task shouldn't be saved to the file,
but it is created automatically when tasks are read from the file. When you add a new task, program should automatically create date from your computer's calendar and give next free number to task number, which is basically the number of existing tasks plus one. When you shutdown the program, it takes care about saving tasks. When you open the program, it reads tasks from the file, if the file exist.

Implement the following subroutines into the program:
- open_file(): it opens file todo.txt and reads tasks in file to the dictionary
- save_file(): it saves tasks in dictionary to todo.txt file. The old file should be replace with the new one.
- add_task(task_description): it creates a new task, which is added to dictionary
- find_tasks(date): finds out every task in the dictionary, that have been created on a specific day(f.ex. 18.5.2020)
- remove_task(number): it removes task from the dictionary by its number
- list_tasks(): it prints all the information from the dictionary

Implement main program to the program, that has menu system to using the program:
It should look like this:

Task management:
1. Print tasks
2. Create a new task
3. Find tasks
4. Remove a task
5. Shutdown the program
Give your choice: __"

Thanks for help in advance, I hope that somebody can help me. I'm in a big trouble with this. :DD
Reply
#2
What have you tried so far ?
Quote:This forum is focused on education. It exists to help people learn Python. We don’t exist to solve others’ problems, although that tends to be a happy byproduct of education
See Homework and No Effort Questions
Reply
#3
Actually, I haven't tried lots of different variations, because I don't even know where to start :D We're having now the programming course in school and this have been the hardest one to me. So, I don't even know how I save information to txt file
:D

Oh, okay I have tried something like that and I think it works like how it should work. (This is a different exercise):

d = {}
products = int(input("How many products you want to save?: "))
for i in range(products):
    name = input("Input the name of the product: ")
    price = input("Input the price of the product: ")
    d[name] = price


print(d)

while True:
    name = input("\nInput the name of the product to see its price: ")
    if name in d:
        print("The price of the product is", name, d[name])
    else:
        print("The product doesn't exist.")

Oh okay, thanks! I'm noob with this website also, like with the Python :D I'll keep that in mind and don't do same mistake again.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020