📘 Keep control flow from meaning spaghetti
Control flow is sequence, selection, and iteration — not spaghetti. Clean conditions and termination make programs predictable.
4
lessons
~20 min
to learn
Adults
level
What you’ll learn
- Sequence, Selection, Iteration: The Three Building BlocksExplain why sequence, selection, and iteration are enough to express a flowchart, and identify each structure in code.Control flow is the rule a language uses to decide what runs next. Böhm and Jacopini (CACM, 1966) showed any flowchart can be rewritten with sequence, selection, and iteration — so an unrestricted goto is never required for expressiveness. You learn to see the default path, the one-of-many path, and the repeating path, and why they nest.
- Boolean Conditions and Selection in DepthBuild correct Boolean conditions with comparison and logical operators, and reason about short-circuit evaluation and multi-way selection.Selection is only as correct as the condition that drives it. This lesson covers comparison versus assignment, and/or/not, precedence, Python truthiness, short-circuit evaluation as a correctness tool, and why C switch falls through while Python match does not.
- Loops, Termination, and Clean Control FlowChoose the right loop, guarantee termination, and use break, continue, and guard clauses without scattering exits.A loop must make progress toward a stopping condition or it hangs. This lesson distinguishes definite from indefinite and pre-test from post-test, treats off-by-one as a boundary-and-invariant problem, and reads Dijkstra's 1968 letter as an argument about coordinates, not a ban on early return.
- Workshop: Build a Control-Flow Mini ArtifactApply sequence, selection, and iteration to build and smoke-test a small number-classification program with validated input.You combine the three structures in one artifact: an indefinite read-until-quit loop, a guard for non-numeric input, a three-way sign chain that includes zero, and a separate parity test. McCabe's M = E − N + 2P, counted on binary predicates, tells you how many independent paths a thorough test would cover — and why five smoke cases are not that set.
Grounded in trusted sources
- Flow Diagrams, Turing Machines and Languages with Only Two Formation Rules — Communications of the ACM 9(5), May 1966 (Corrado Böhm and Giuseppe Jacopini)
- Go To Statement Considered Harmful — Communications of the ACM 11(3), March 1968 (Edsger W. Dijkstra)
- Truth Value Testing and Boolean Operations — Python Software Foundation — Library Reference
- More Control Flow Tools — Python Software Foundation — Tutorial §4 (if, for, break/continue, match)
- Structured Testing: A Testing Methodology Using the Cyclomatic Complexity Metric — NIST Special Publication 500-235 (Watson and McCabe, 1996) — restates McCabe 1976
- switch statement — cppreference — C fall-through without break
- Corrado Böhm and Giuseppe Jacopini, 'Flow Diagrams, Turing Machines and Languages with Only Two Formation Rules,' Communications of the ACM 9(5), May 1966, pp. 366–371.
- Python Software Foundation, '4. More Control Flow Tools,' The Python Tutorial.
Every Wunder lesson is built from real, reputable sources — never invented.
Related courses
📘Keep garden calendar from meaning toy📘Keep clinical manual from meaning advice📘How do functions hide complexity in code?📘How do data structures trade time for space?📘How do you build a solid CLI?📘How does object-oriented Python work?📘How do HTML and CSS structure a page?📘How does JavaScript run in the page?
Wunder is a personalized learn-anything platform — tell it any topic and it builds a beautiful, fact-checked course in minutes, with narration, a knowledge check, and a college-style University track.
© 2026 Wunder Learning LLC · Terms & Privacy