Project: CLI Task Manager
Put your knowledge of functions, logic, and files into practice by building a real application
Learning Objectives
- Organize code into functional blocks
- Implement a persistent storage system using text files
- Handle user input and application flow
- Practice basic error handling
Week 2 Milestone
Congratulations on finishing Week 2! You’ve learned about functions, scope, errors, and files. Now it’s time to bring it all together by building a Command Line Task Manager.
Project Requirements
Your application should allow a user to:
- View all tasks.
- Add a new task.
- Delete a task.
- Save tasks to a file (
tasks.txt) so they are still there when the program restarts.
Step 1: Planning the Functions
Break the problem down into smaller tasks:
load_tasks(): Read from the file and return a list.save_tasks(tasks): Write the current list to the file.show_menu(): Print the user options.main(): The loop that runs the app.
Step 2: Implementation Starter
task_manager.py
|
|
Your Challenge
Enhance the project with these features:
- Delete Functionality: Ask for a task number and remove it from the list.
- Error Handling: Use
try...exceptto handle cases where the user enters a non-number for deletion. - Clear UI: Add some spacing or dividers to make the output look nice.
Interactive Practice
How would you visualize the loop of this application?
flowchart TD
Start([Start]) --> Load[Load tasks.txt]
Load --> Menu[Display Menu]
Menu --> Input[Get User Choice]
Input --> Action{Choice?}
Action -- 1 --> View[Print List]
Action -- 2 --> Add[Add to list & Save]
Action -- 3 --> Del[Remove & Save]
Action -- 4 --> Exit([End])
View --> Menu
Add --> Menu
Del --> Menu
Quiz
Complete this quiz with a minimum score of 80% to mark Day 14 as complete.
Loading quiz...
Discussion
Have questions or want to discuss this lesson? Join the conversation below!