Python

 

Introduction

A task reminder application helps users stay organized by reminding them of important tasks they need to complete. With this program, users can add tasks with their description, date, and time, and receive reminders when the task is due. This is a useful tool for managing personal tasks or work deadlines.

Objective

The main objective of this task reminder application is to allow users to store their tasks and receive notifications when the tasks are due. The program will be built using Python and will have a simple text-based interface for interaction. The task data will be stored locally, and the application will run in the background to notify users about upcoming tasks.

Python Code for Task Reminder Application

import time
import datetime

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

    def add_task(self, task_description, due_date, due_time):
        task = {"description": task_description, "due_date": due_date, "due_time": due_time}
        self.tasks.append(task)
        print(f"Task '{task_description}' added successfully!")

    def check_reminders(self):
        current_time = datetime.datetime.now()
        for task in self.tasks:
            task_due_datetime = datetime.datetime.combine(task['due_date'], task['due_time'])
            if current_time >= task_due_datetime:
                print(f"Reminder: Task '{task['description']}' is due now!")
            else:
                time_remaining = task_due_datetime - current_time
                print(f"Task '{task['description']}' will be due in {time_remaining}.")
    
    def run(self):
        while True:
            print("\nTask Reminder Application")
            print("1. Add Task")
            print("2. Check Reminders")
            print("3. Exit")
            choice = input("Enter your choice: ")

            if choice == "1":
                task_description = input("Enter task description: ")
                due_date_str = input("Enter task due date (YYYY-MM-DD): ")
                due_time_str = input("Enter task due time (HH:MM): ")

                due_date = datetime.datetime.strptime(due_date_str, "%Y-%m-%d").date()
                due_time = datetime.datetime.strptime(due_time_str, "%H:%M").time()

                self.add_task(task_description, due_date, due_time)

            elif choice == "2":
                self.check_reminders()

            elif choice == "3":
                print("Exiting Task Reminder Application.")
                break
            else:
                print("Invalid choice. Please try again.")

if __name__ == "__main__":
    reminder = TaskReminder()
    reminder.run()

Program Explanation

This Python program allows users to add tasks, check reminders, and receive notifications when a task is due. Here’s a breakdown of the program structure:

  • TaskReminder Class: Contains methods to manage tasks, add new tasks, and check reminders.
  • add_task Method: Accepts task description, due date, and due time as input and stores the task in the tasks list.
  • check_reminders Method: Checks if any tasks are due and notifies the user accordingly.
  • run Method: The main loop of the application, which provides a simple text-based menu for the user to interact with the program.

How to Run the Program:

1. Make sure you have Python installed on your computer.

2. Copy the Python code and save it as a file with a .py extension (e.g., task_reminder.py).

3. Open your command-line interface (CLI) or terminal.

4. Navigate to the directory where the Python file is saved.

5. Run the program by typing: python task_reminder.py and hit Enter.

6. Follow the on-screen instructions to add tasks, check reminders, or exit the application.

© 2025 Learn Programming. All Rights Reserved.

 

By Aditya Bhuyan

I work as a cloud specialist. In addition to being an architect and SRE specialist, I work as a cloud engineer and developer. I have assisted my clients in converting their antiquated programmes into contemporary microservices that operate on various cloud computing platforms such as AWS, GCP, Azure, or VMware Tanzu, as well as orchestration systems such as Docker Swarm or Kubernetes. For over twenty years, I have been employed in the IT sector as a Java developer, J2EE architect, scrum master, and instructor. I write about Cloud Native and Cloud often. Bangalore, India is where my family and I call home. I maintain my physical and mental fitness by doing a lot of yoga and meditation.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)