Editor

Complete Budget Report

Intermediate · Write the code · from Build a Budget Tracker and Expense Analyzer

From the lesson: Step 6: Generate the Budget Report

The final step is putting everything together into a complete budget report with recommendations. A good budget report tells you what happened, highlights the problems, and suggests what to do about them.

Read this part of the lesson

Write a function budget_report(df, budget_limits) that prints a complete budget report:

1. Header: "MONTHLY BUDGET REPORT" with = separators

2. Overview: Total spent, total budget, and overall status

3. Category breakdown: Each category showing spent vs budget and status

4. Recommendations: For each over-budget category, suggest reducing spending

Use this exact format:

==============================
  MONTHLY BUDGET REPORT
==============================
Total Spent:  $XXX.XX
Total Budget: $XXX.XX
Status: Under budget / OVER BUDGET
------------------------------
Category Breakdown:
  Food:          $XXX.XX / $XXX.XX [STATUS]
  ...
------------------------------
Recommendations:
- Reduce CATEGORY spending by $XX.XX
==============================
import pandas as pd
def budget_report(df, budget_limits):
# Your code here
pass
data = {
'description': ['Grocery store', 'Restaurant', 'Electric bill',
'Movie tickets', 'Concert', 'Gas station', 'Gym'],
'category': ['Food', 'Food', 'Utilities',
'Entertainment', 'Entertainment', 'Transport', 'Health'],
'amount': [120.00, 85.00, 150.00, 45.00, 95.00, 40.00, 30.00]
}
df = pd.DataFrame(data)
budget = {'Food': 200.00, 'Utilities': 300.00, 'Entertainment': 100.00,
'Transport': 150.00, 'Health': 75.00}
budget_report(df, budget)

More Budget Tracker exercises

All Python exercises · 50 practice problems · Practical Projects quiz