Pebellslearn by building
0%
RoadmapMatrixCatalogSandboxSign in
Fundamental's Follow up Projects  ›  Capstone Project

Project 3 — Expense & Budget Tracker

Capstone Project 40 minTally spending by category, compare against budgets, and report
Your task
Build monthly_report(expenses, budgets): tally spend per category, then return {"total", "by_category", "over": sorted categories over their budget, "top": the biggest-spend category (or None)}.

Project 3 — Expense & Budget Tracker

A money app in miniature. Log expenses by category, compare spend against budgets, and surface what matters: total, per-category breakdown, over-budget alerts, and your biggest spending category.

Build the four steps, then assemble monthly_report(expenses, budgets).

  • Step 1 — add_up: total all expenses.
  • Step 2 — by_category: {category: total}.
  • Step 3 — over_budget: which categories blew their limit.
  • Step 4 — top_category: the biggest spender.

Skills: dict tallying with .get, comprehensions, sorted, max(key=…), guards.

Practice — level up

0/4 solved

Solve each in its own editor — Run to try, Check to grade. Stuck? Reveal a Hint, or the full Solution + walkthrough.

BuildStep 1 — Total spend

An expense is {"category": str, "amount": number}. Write add_up(expenses) returning the total amount.

dict-accesssum
BuildStep 2 — Group by category

Write by_category(expenses) returning {category: total_spent}.

setdefault/getloop
BossStep 3 — Over budget

Given spent {category: amount} and budgets {category: limit}, write over_budget(spent, budgets) returning the sorted categories whose spend exceeds their limit. A category with no budget is never over.

dictcomprehensionsorted
BossStep 4 — Biggest category

Write top_category(expenses) returning the category with the highest total spend (or None if empty).

groupmax-keyguard
monthly_report.py
Call the function you wrote — just like your app's frontend would. Edit the inputs and hit Call.
monthly_report(expenses, budgets) → dictTally spending by category, compare against budgets, and report
try:
returned
No app map for this section yet.
Press Run to execute your code.
Press Check to run the tests for this lesson.