Skip to content
  • Home
  • How To
  • M0
  • Module 1 - Python
  • Agents
  • M2
  • M3
  • M4
  • M5
  • M6
  • Progress
  • Contact
  • Pricing
  • Sign in
  • Future
  1. Module 1M1
  2. ›
    S2Control Flow
  3. ›
    Intro
  4. ›
    S2›Intro
  1. Module 1
  2. ›
  3. Section 2

Section 1.2: Control Flow

A program that runs top to bottom once can only ever do one fixed thing. Control flow is what lets it decide and repeat: taking one branch instead of another based on a condition, running a block until something changes, and walking every item of a collection in turn. The subtlety is not the syntax, it is truthiness, the rule Python uses to treat non-boolean values as true or false, and the loop that never terminates because the condition it depends on is never updated.

Section 1 gave you values, names and operators, which is enough to compute a single result. What it left unfinished is everything that depends on the result. A metric you can compare against a threshold but cannot act on does not change what the program does, and a sweep over twenty hyperparameter values written as twenty copied lines is not a sweep, it is a transcription error waiting to happen.

Lessons

  1. Conditionals - if, elif, else, and Truthiness - branching on a condition, and which values count as true.
  2. The while Loop and the Accumulator Pattern - repeating until a condition changes, and building a result up across iterations.
  3. The for Loop, Iterables, and range - walking every item of a collection in order.
  4. Controlling Loops - break, continue, and Nesting - leaving early, skipping an iteration, and putting one loop inside another.

By the end you will be able to:

  • Predict which branch of a conditional runs, including for non-boolean conditions.
  • Write an accumulator loop that produces a correct running total or count.
  • Choose between a for loop and a while loop from the problem statement alone.
  • Trace a nested loop's execution and say exactly how many times the inner body runs.
Your progress
Current streak
🔥 0
Lessons marked today
0 / 3
Longest streak
0

Sign in

The bootcamp

  • Curriculum
  • How To
  • Pricing
  • Changelog
  • Future

The community

  • Discord
  • Reviews
  • Contact

Follow

  • Instagram
  • X
  • TikTok
  • Reddit

Legal

  • Terms
  • Privacy
  • Refunds

Coming soon on November 16, 2026

The AI/ML Newsletter, free.

SubscribeComing soon on December 1, 2026

Confirm by email, unsubscribe in one click.

Theme