Skip to Content
SBA

Python Essentials 2

Overview and Objectives

In this project you will design and implement a Personal To-Do List Manager that integrates various Python concepts learned throughout the course, including modules, file handling, and object-oriented programming. You will:

  • Create a Task class to represent individual to-do items.
  • Develop functions (or methods) for adding, completing, deleting, and listing tasks.
  • Build a text-based user interface that enables interactive management of tasks.
  • Implement data persistence by saving tasks to and loading them from a file.
  • (Optional) Enhance your program with an external package for improved output formatting or additional features.

By the end of this project, you will have a fully functional console application that allows users to manage their daily tasks effectively.

Instructions and Tasks

Task 1: Define the Task Class

  • Create a new module (e.g., task.py) and define a class Task with the following:
    • Attributes:
      • title: A short description of the task.
      • due_date: An optional due date (as a datetime.date object or a string).
      • completed: A boolean status indicating whether the task is complete.
    • Initializer:
      • __init__(self, title, due_date=None, completed=False) to set up the attributes.
    • Methods:
      • __str__(self): Returns a well-formatted string representation of the task, e.g., "[-] Submit assignment (due 2025-03-10)", where [X] indicates a completed task.

Task 2: Implement To-Do Manager Functions

  • Create a new module (e.g., todolist.py) that includes functions to manage tasks:
    • add_task(task_list, title, due_date=None): Creates a new Task and adds it to the list. If due_date is provided as a string, parse it into a datetime.date (assume format “YYYY-MM-DD”). Use exception handling to catch parsing errors and inform the user.
    • complete_task(task_list, index): Marks the task at the given index as completed. If the index is invalid, handle the error gracefully.
    • delete_task(task_list, index): Removes the task at the given index. Include error handling for invalid indices.
    • list_tasks(task_list): Returns or prints a formatted list of tasks showing index, status, title, and due date. Indicate if a task is overdue by comparing the due date with today’s date.

Task 3: Develop the User Interface

  • Create a main script (e.g., main.py) that:
    • Presents a text-based menu with the options:
      • (A) Add a new task.
      • (C) Mark a task as completed.
      • (D) Delete a task.
      • (L) List all tasks.
      • (Q) Quit.
    • Implements the menu loop so that after each operation the menu is shown again until the user chooses to quit.
    • For each menu option, prompts the user for necessary input and calls the corresponding function from todolist.py.
    • Before quitting, prompts the user to save the current task list to a file.

Task 4: Data Persistence

  • Enhance your program to save tasks to a file (e.g., tasks.txt or tasks.csv) and load them on startup:
    • When the program starts, check if the file exists using the os module. If it exists, load the tasks and reconstruct the Task objects.
    • When the user chooses to save (or upon exiting), write the tasks to the file in a structured format (e.g., comma-separated values).
    • Use try/except blocks to handle potential file I/O errors, providing user-friendly error messages.

(Optional) Task 5: External Package Enhancement

  • Optionally, use a third-party package (such as colorama or prettytable) to enhance the user interface:
    • For example, color-code overdue tasks or format the task list as a table.
    • Include a comment at the top of your code explaining how to install the package (e.g., # Requires colorama; install with: pip install colorama).

Submission

Submit the following files via a link to a single GitHub repository containing all the files.:

  • task.py (containing the Task class)
  • todolist.py (containing functions for task management)
  • main.py (the main user interface script)
  • Any additional files if you implement optional enhancements

Include sample outputs (screenshots or text logs) demonstrating:

  • Successful creation, completion, deletion, and listing of tasks.
  • Data persistence: tasks being saved to and loaded from a file.
  • (Optional) Enhanced user interface output if external packages are used.

Grading Rubric

CriteriaPointsDescription
Program Functionality (Task Operations)50 ptsAll core features work correctly: adding tasks (with due date parsing), marking tasks as complete, deleting tasks, and listing tasks with clear formatting. Full credit if every operation works as specified, including overdue checks. Partial credit for minor issues or incomplete features.
Data Persistence (File Save/Load)15 ptsThe program successfully saves tasks to a file upon exit (or on demand) and loads existing tasks on startup. Full credit if the file format preserves task details (title, due date, completion status) and error handling is implemented.
Object-Oriented Design and Modularity15 ptsThe solution makes appropriate use of classes and functions. The Task class is well-defined, and task management operations are modularized in a separate module. Full credit if the code is organized into distinct, reusable components.
Exception Handling and Robustness10 ptsThe program uses try/except blocks to handle potential errors (e.g., invalid date input, file I/O errors, invalid indices). Full credit if exceptions are caught with clear messages and the program does not crash under erroneous input.
User Interface and Experience5 ptsThe menu and prompts are clear and user-friendly. Task outputs are neatly formatted, and the overall user experience is intuitive. Partial credit for minor usability issues.
Code Quality and Documentation5 ptsCode is well-organized, with meaningful names, proper indentation, and appropriate comments/docstrings explaining key sections. Deduct points for disorganized or poorly commented code.

Total Points: 100 points

Note

Partial credit will be awarded for submissions that demonstrate a clear understanding of the required concepts even if some elements are incomplete or contain minor errors. For example, if the task management functions work correctly but data persistence has minor formatting issues, evaluators will award points proportional to the correct work submitted. Points may be deducted for missing features, errors in exception handling, or poorly organized code; however, credit will be given where the overall approach is sound and the code clearly attempts to meet the rubric criteria.