create a planner in python

Here is a basic skeleton code for creating a planner in Python using the datetime module:

main.py
import datetime

class Planner:
    def __init__(self):
        self.tasks = []

    def add_task(self, task):
        self.tasks.append(task)

    def get_tasks(self):
        return self.tasks

    def remove_task(self, task):
        self.tasks.remove(task)

    def print_tasks(self):
        for task in self.tasks:
            print(task)

class Task:
    def __init__(self, description, day, time):
        self.description = description
        self.day = day
        self.time = time

    def __str__(self):
        return f"{self.description} on {self.day} at {self.time}"

planner = Planner()

task1 = Task("Meeting with client", datetime.date(2022, 4, 12), datetime.time(14, 30))
task2 = Task("Prepare presentation", datetime.date(2022, 4, 11), datetime.time(10, 0))

planner.add_task(task1)
planner.add_task(task2)

planner.print_tasks()
851 chars
38 lines

This code defines two classes: Planner and Task. The Task class defines a task with a description, the date on which it needs to be completed, and the time at which it needs to be completed. The Planner class functions as a container for tasks and includes methods for adding, removing, and printing tasks.

In the example code, we create a Planner object, and then create two Task objects with specific dates and times. We add these tasks to the planner using the add_task method and print out all tasks using the print_tasks method.

You can modify this code to include additional features, such as repeating tasks, reminders, and priority levels.

gistlibby LogSnag