python · level 2 check
a budget tracker.
Time to build something useful: a budget tracker. Type each spend as a category, a comma and an amount, like `food, 4.50`, then type `done`. The tracker saves every spend to its own CSV file, then reads the file back to build its report.
`read_entry` splits a line and raises a ValueError for anything it cannot use. `Budget.add` refuses amounts that are not more than zero, then adds a row to the CSV. `Budget.totals` reads the rows back and keeps a tally for each category.
The report lists categories A to Z in lined-up columns, adds a total and names your biggest category. Your file starts empty on every run. Fill in each `____`, then run it.
Fill in every ____ then run the checks.
- 1 It saves spends to its CSV and adds them upuses: files and CSV
- 2 It keeps categories apart and lists them A to Zuses: dictionaries and sorting
- 3 It skips a line without a commauses: splitting text
- 4 It refuses amounts that are not numbers or not above zerouses: raising errors
- 5 It prints a lined-up total and the biggest categoryuses: formatting numbers
- 6 It copes with no spending at alluses: catching errors
Take as long as you like and try as many times as you want.
python · level 2 · medium
level up.
You passed every check. Your face is now B).
- 28 lessons in this level
- 6 of 6 checks passed
This pass isn’t saved. A free account keeps your new face.