Free lab Real Python 3. Zero installs. Your code stays in this browser. Open the playground

Sales Report Generator

From raw CSV export to an executive report: parse sales data, compute revenue by product and month, find the winners, and generate the summary a manager actually reads.

Intermediate 4 steps 110 XP ~45 min

How it works in the real world

This is the daily reality of data analysts and the core of every BI tool (Tableau, Power BI, Excel pivot tables):

  1. Extract — parse the CSV export (with the csv module — never by hand).
  2. Transform — convert types (CSV is all strings!) and aggregate revenue by product and by month.
  3. Analyse — rank: top product, best month.
  4. Load/Report — output the formatted summary.

Data engineers call this pipeline ETL. You're about to build one end-to-end.

Build progress0 / 4 steps
1

Extract: parse the CSV

Parse raw with csv.DictReader, then print the number of rows and the first row's product: 6 then laptop.

Blank · autosaved
PYstep_1.py
Run your code to check this step…
2

Transform: revenue per product

Revenue for a row is units × price (convert to int!). Total it per product and print each as product: revenue in first-seen order.

Blank · autosaved
PYstep_2.py
Run your code to check this step…
3

Analyse: revenue per month

Aggregate revenue per month, print each as month: revenue, then Best month: Mar.

Blank · autosaved
PYstep_3.py
Run your code to check this step…
4

Report: the executive summary

Combine everything into the final report — exactly:
=== Q1 Sales Report ===
Total revenue: 8850
Top product: laptop (8100)
Best month: Mar (3800)

Blank · autosaved
PYstep_4.py
Run your code to check this step…
Your next ten minutes

Write Python that does something useful.

Start free. No install, no card, no passive video marathon.

Start learning free → Explore the path