Objective & prerequisites
Distinguish successful execution from successful analysis. Prerequisites: basic Python expressions and files; use a disposable local practice folder and fictional data. This shared workshop complements the existing data/AI tracks and does not create a second progress system.
Understand the concept
A process exit status reports whether the program signalled success, not whether its business conclusion is correct. Standard output is commonly used for results and standard error for diagnostics. Logs should identify stage, time, record counts and error category without copying private records or credentials. A pipeline needs both process-level status and domain validation.
Worked example
The supplied unittest command exits nonzero if an assertion fails. safe_total also rejects duplicate IDs and boolean money values. A syntactically valid program returning the wrong total is still a failed analytical task.
python3 foundation_labs.py FoundationTests.test_contract_rejects_boolTry it yourself
Predict what happens when amount_cents is True rather than 1. Run the focused rejection test and write a safe diagnostic that identifies the rejected field without exposing a customer record. Record your prediction before running the supplied reference, then compare the observed result and explain any difference.
Worked solution
The contract rejects True because type(value) is int is required; Python bool is otherwise a subclass of int. A safe log might say validation_failed field=amount_cents category=invalid_type count=1. Do not log the entire payload.
Knowledge check
Does a zero exit code alone prove the source was complete? Try answering without rereading the example.
Check and explain
No. Explicit domain checks and reconciled totals establish the narrower result being claimed.
Mini-project, mistakes & handover
Produce a short README with the question, exact local command, input meaning, checks and actual results. Include one failure case and its explanation. Never silently turn an exception into a passing result. Mark simulated behavior explicitly, credit the supplied teaching code and identify your own contribution. These activities are unsaved self-practice, not certification.
Authoritative reference
— consulted for the underlying interface/concept. The lesson and fictional examples are original teaching material. Python reference tested with 3.12; designed for 3.10+. Git lab requires Git 2.28+.
Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.