Untitled
class Task: task_counter = 0 def __init__(self, title, description, due_date): Task.task_counter += 1 self.id = Task.task_counter self.title = title self.description = description self.due_date = due_date self.status = "Incomplete" def update_task(self, title=None, description=None, due_date=None, status=None): if title: self.title = title if description: self.description = description if due_date: self.due_date = due_date if status: self.status = status def delete_task(self): del self def display_task(self): print(f"Task ID: {self.id}") print(f"Title: {self.title}") print(f"Description: {self.description}") print(f"Due Date: {self.due_date}") print(f"Status: {self.status}\n") # create task1 = Task("Learn Python", "Complete Python tutorial", "2024-08-10") task2 = Task("Grocery Shopping", "Buy fruits and vegetables", "2024-08-11") #display task1.display_task() task2.display_task() # update task1.update_task(status="Complete") task1.display_task() # delete task2.delete_task()
Leave a Comment