222.1 Class design / Task
This section introduces the Task class, which defines the structure and behaviour of individual tasks in the Task Tracker app.
Last updated
Was this helpful?
This section introduces the Task class, which defines the structure and behaviour of individual tasks in the Task Tracker app.
Last updated
Was this helpful?
Was this helpful?
class Task:
def __init__(self, title, description, due_date):
self.title = title
self.description = description
self.due_date = due_date
self.is_complete = False
def mark_complete(self):
self.is_complete = True
def mark_incomplete(self):
self.is_complete = False
def display_summary(self):
status = "✓" if self.is_complete else "✗"
print(f"{self.title} [{status}]")
def display_details(self):
status = "Complete" if self.is_complete else "Incomplete"
print(f"Title: {self.title}")
print(f"Description: {self.description}")
print(f"Due: {self.due_date}")
print(f"Status: {status}")