Skip to content

Instantly share code, notes, and snippets.

@tabiodun
Created January 19, 2025 17:37
Show Gist options
  • Save tabiodun/4bdfacf7bd0b63ba169f893d8858d199 to your computer and use it in GitHub Desktop.
Save tabiodun/4bdfacf7bd0b63ba169f893d8858d199 to your computer and use it in GitHub Desktop.

Python Programming Assignment: Expense Tracker Application

Objective

Develop a console-based Expense Tracker application in Python that allows users to monitor and manage their daily expenses. This project will help you practice fundamental Python concepts such as data structures, file handling, user input, and functions.

Requirements

1. Add Expense

  • Functionality: Allow users to input new expenses with the following details:
    • Amount: A positive number representing the cost.
    • Category: Select from predefined categories (e.g., Food, Transportation, Entertainment, Utilities, Others).
    • Description: A brief description of the expense.
    • Date: The date of the expense in YYYY-MM-DD format. If not provided, default to the current date.

2. View Expenses

  • Functionality: Display a list of all recorded expenses in a clear, tabular format showing:
    • Amount
    • Category
    • Description
    • Date

3. Summary Report

  • Functionality: Provide a summary that includes:
    • Total expenses per category.
    • Overall total expenses.

4. Data Persistence

  • Functionality:
    • Save all expenses to a JSON file (e.g., expenses.json) to ensure data is retained between program runs.
    • Load existing expenses from the JSON file when the application starts.

5. User Interface

  • Functionality: Implement a simple text-based menu that allows users to navigate between different functionalities:
    • Add Expense
    • View Expenses
    • Summary Report
    • Exit

6. Input Validation

  • Functionality: Ensure that all user inputs are validated:
    • Amount: Should be a positive number.
    • Category Selection: Should be within the predefined options.
    • Date: Should follow the YYYY-MM-DD format.
    • Handle invalid inputs gracefully by displaying appropriate error messages.

Optional Enhancements (For Extra Challenge)

  • Date Range Filtering: Allow users to view expenses within a specific date range.
  • Graphical Reports: Use libraries like matplotlib to visualize spending trends with charts or graphs.
  • User Authentication: Implement user accounts to manage expenses for different individuals.
  • Recurring Expenses: Handle expenses that occur regularly (e.g., monthly subscriptions).
  • Export Data: Provide an option to export expenses to formats like CSV or Excel.

Technical Guidelines

  • Programming Language: Python (version 3.x)
  • Data Storage: JSON file for saving and loading expenses.
  • Libraries: You may use Python's standard libraries such as json, os, and datetime. For optional enhancements like graphical reports, you can use external libraries like matplotlib.
  • Code Structure:
    • Use functions to organize different parts of the application (e.g., adding an expense, viewing expenses, generating reports).
    • Keep the code modular and readable with proper naming conventions and comments.

Submission Instructions

1. Code

  • Requirement: Submit the Python script (.py file) containing your Expense Tracker application.
  • Note: Ensure that your code is well-documented with comments explaining key sections and functionalities.

2. Documentation

  • Requirement: Include a brief README file that describes:
    • How to run the application.
    • Any external libraries used (if applicable).
    • Features implemented, including any optional enhancements.

3. Demonstration

  • Optional: Provide sample screenshots or a short video demonstrating the application's functionalities.

Evaluation Criteria

  • Functionality: The application meets all the required features and works as expected.
  • Code Quality: Code is clean, well-organized, and follows best practices.
  • User Experience: The interface is user-friendly, and inputs/outputs are handled gracefully.
  • Error Handling: The application properly manages invalid inputs and unexpected errors.
  • Creativity: Implementation of optional enhancements and any additional useful features.

Getting Started Tips

  • Plan Your Project:

    • Outline the features you want to implement.
    • Break down the project into smaller tasks (e.g., creating the menu, handling user input, managing data storage).
  • Start Small:

    • Begin with the core functionalities like adding and viewing expenses before moving on to summary reports and data persistence.
  • Test Frequently:

    • Regularly test each feature as you build to ensure everything works correctly.
  • Seek Feedback:

    • Share your progress with peers or mentors to get constructive feedback and suggestions.
  • Explore Documentation:

    • Familiarize yourself with Python’s json, os, and datetime modules to effectively handle data storage and date operations.
@tabiodun
Copy link
Author

Example Workflow

1. Launch Application

=== Expense Tracker ===
1. Add Expense
2. View Expenses
3. Summary Report
4. Exit
Select an option: 

2. Add an Expense

Enter amount: $25.50
Select category:
1. Food
2. Transportation
3. Entertainment
4. Utilities
5. Others
Enter category number: 1
Enter description: Lunch at cafe
Enter date (YYYY-MM-DD) or press Enter for today: 
Expense added successfully!

3. View Expenses

=== All Expenses ===
Amount    Category       Description           Date       
------------------------------------------------------------
$25.50    Food           Lunch at cafe         2025-01-18
$15.00    Transportation Bus ticket            2025-01-18

4. Summary Report

=== Expense Summary ===
Food: $25.50
Transportation: $15.00
Total Expenses: $40.50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment