Python Essentials · 35 min · 250 XP

Capstone: inventory report

Build a second file-processing automation from a fresh brief, including validation and exact money arithmetic.

This is the independent capstone. It deliberately does not repeat the sales-report recipe. Use earlier lessons as references, but make your own plan before opening the hint.

Reliable automation has an explicit contract: required columns, valid values, output order, error behaviour and a summary of what it skipped. Decimal is used for money because binary floating-point cannot represent many decimal amounts exactly. Construct it from CSV text, not from a float: Decimal(row["unit_price"]).

Treat a missing file differently from a bad row. Let FileNotFoundError explain that the requested input does not exist. Reject a wrong header with a clear ValueError. Skip individual malformed records and report the number skipped so the output is useful without pretending every source row was valid.

Loading your workspace…