Skip to content
# Start coding here...
import datetime
class TimeManager:
def __init__(self):
self.current_time = datetime.datetime.now()
def get_current_time(self):
self.current_time = datetime.datetime.now()
print("Current time:", self.current_time.strftime("%H:%M:%S"))
def start_stopwatch(self):
start_time = datetime.datetime.now()
input("Press Enter to stop the stopwatch.")
end_time = datetime.datetime.now()
elapsed_time = end_time - start_time
print("Elapsed time:", elapsed_time)
class Calendar:
def __init__(self):
self.appointments = {}
def create_appointment(self, date, description):
if date in self.appointments:
self.appointments[date].append(description)
else:
self.appointments[date] = [description]
def view_appointments(self, date):
if date in self.appointments:
print("Appointments for", date)
for appointment in self.appointments[date]:
print("-", appointment)
else:
print("No appointments for", date)
class ToDoList:
def __init__(self):
self.tasks = []
def add_task(self, task):
self.tasks.append(task)
def remove_task(self, task):
if task in self.tasks:
self.tasks.remove(task)
def view_tasks(self):
print("To-Do List:")
if self.tasks:
for i, task in enumerate(self.tasks, 1):
print(f"{i}. {task}")
else:
print("No tasks.")
class YearPlanner:
def __init__(self):
self.events = {}
def add_event(self, month, day, event):
key = f"{month}-{day}"
if key in self.events:
self.events[key].append(event)
else:
self.events[key] = [event]
def view_events(self, month, day):
key = f"{month}-{day}"
if key in self.events:
print("Events for", key)
for event in self.events[key]:
print("-", event)
else:
print("No events for", key)
def main():
time_manager = TimeManager()
calendar = Calendar()
todo_list = ToDoList()
year_planner = YearPlanner()
while True:
print("\nPhone Application")
print("1. Time Management")
print("2. Stopwatch")
print("3. Calendar")
print("4. To-Do List")
print("5. Year Planner")
print("0. Exit")
choice = input("Enter your choice: ")
if choice == "1":
time_manager.get_current_time()
elif choice == "2":
time_manager.start_stopwatch()
elif choice == "3":
print("\nCalendar")
print("1. Create Appointment")
print("2. View Appointments")
print("0. Back")
calendar_choice = input("Enter your choice: ")
if calendar_choice == "1":
date = input("Enter date (YYYY-MM-DD): ")
description = input("Enter appointment description: ")
calendar.create_appointment(date, description)
elif calendar_choice == "2":
date = input("Enter date (YYYY-MM-DD): ")
calendar.view_appointments(date)
elif calendar_choice == "0":
continue
elif choice == "4":
print("\nTo-Do List")
print("1. Add Task")
print("2. Remove Task")
print("3. View Tasks")
print("0. Back")
todo