๐Ÿ“Š We use cookies & analytics to improve your experience. Learn more
Latest

Python for Absolute Beginners Module 5 ยท Lesson 13 of 15

0% Exit to course

Module 5 ยท Three projects and a shareable repo Lesson 13 of 15

Project 1 โ€” Expense tracker

Learning objective

A menu-driven program that records expenses, saves them to a CSV and prints a monthly total per category. It exercises input, loops, dictionaries and files in one piece of work.

The concept

An expense tracker is a menu-driven program: add an expense, list this month's expenses, show the total per category, quit. It is the smallest project that uses everything in the first four modules at once โ€” input, conditions, loops, functions, dictionaries and file writing โ€” which is why it is project one rather than a bigger, half-finished idea.

A single expenses.csv with the columns date, category, amount is the whole storage layer. No database, no framework, nothing a reviewer has to install to run โ€” a person who can open your project with one command is a person who will actually read it. Read the file into a list of dictionaries at start-up, add to the list as the user works, and write the whole list back when they choose to save.

Common mistakes

The mistake that makes this project fail is building the interface first and the data second. Write the file format down, write one function that parses a line into a dictionary, then build the menu around functions you already know work. It also needs to survive being closed: start it twice, add an expense each time, and check the first one is still there.

Worked example

A single expense.csv with columns date, category, amount is enough โ€” no database, no framework, nothing that can fail to install on a reviewer's machine.

Your practice task

Build it end to end and make sure it survives being closed and reopened without losing the earlier entries.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

An expense tracker is a menu-driven program: add an expense, list this month's expenses, show the total per category, quit.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task โ€” do them and the final project brief writes itself.