Sequences and loops
Process repeated cases and build a reproducible simulation pipeline
Most useful programs work with more than one value. They process orders, customers, measurements, or simulated trials repeatedly and collect results in a structured form. Sequences and loops make that repetition explicit, while careful state design prevents skipped cases, infinite loops, and irreproducible results.
This part connects fundamental iteration to a minimum viable simulation. You will use controlled randomness, repeat an experiment, collect one result per run, and transfer the resulting table to Excel for inspection.
Learning objectives
By the end of this part, you will be able to:
- create, inspect, copy, update, and traverse Python sequences;
- select a suitable data structure for ordered, tabular, or nested values;
- construct
forandwhileloops with explicit state and termination; - build counters, accumulators, filters, and result collections;
- diagnose off-by-one errors, unintended mutation, and non-terminating loops;
- use a local random-number generator and seed to reproduce generated results;
- implement a small simulation with scenarios and repeated trials; and
- export a stable results table to CSV and inspect or refresh it in Excel.
This page previews Module 5. Canvas announces when its detailed chapters become available on the public course site.