Loading
0x90Lesson 10 of 10

Automation lab: build a sales summary script

Combine parsing, loops, functions, and validation in a practical mini-lab.

12 min 5-question quiz 1 code exercise
By the end of this lesson you can
  • Generate a region-level sales summary from raw records.

A realistic beginner automation task is transforming raw text records into a concise summary report. This combines multiple fundamentals: string parsing, dictionaries, loops, and defensive input handling.

main.py
1records = ["north,120", "south,90", "north,30"]
2summary = {}
3for row in records:
4    region, amount = row.split(",")
5    summary[region] = summary.get(region, 0) + int(amount)
6print(summary["north"], summary["south"])
Output
150 90

This pattern appears in lightweight analytics jobs, ops dashboards, and support reporting scripts. Keep record parsing explicit and report generation deterministic.

Key takeaways

  • Generate a region-level sales summary from raw records.

  • Read the output to check what your program did.

  • Keep indentation consistent in Python blocks.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write Python

Write Python in the editor and run it against sample inputs. Python runs locally in your browser using a WebAssembly runtime.

Exercise 1

Build a two-region sales report

+25 XP

Read integer n, then n lines in format region,amount. Regions are north or south. Ignore invalid amount rows. Print north=<total>; south=<total>.

  • Valid and invalid rows
  • Unknown region ignored
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…