MODULE 03 · BEGINNER

Decisions and repetitionPython · Module 3

Direct a program with conditions, process collections with loops, and build readable comprehensions.

6 lessons24 min readingWrite clear Python
Free, self-paced, and open to everyone. No account needed.
WHAT THIS MODULE COVERS

Decisions and repetition

Direct a program with conditions, process collections with loops, and build readable comprehensions.

BEFORE YOU START

Collections (lists, dicts, sets) and comparison operators.

WHAT YOU’LL BE ABLE TO DO

Express complex rules with conditionals, process collections efficiently with loops, and repeat work with clear stopping conditions and proper iteration patterns.

THE LESSON SEQUENCE

Read in order, or jump to what you need.

Every lesson builds on the one before it. Open any lesson to read the explanation, run the examples, and try the practice challenges.

  1. 03.01
    Conditions and boolean logic

    Translate rules into precise tests and choose branches that handle boundary cases correctly.

    4 min
  2. 03.02
    Pattern matching with match and case

    Express branching rules by the shape of data, add guards for conditions, and keep captures readable.

    4 min
  3. 03.03
    For loops and range

    Process each item in a sequence and build useful totals without duplicating instructions.

    4 min
  4. 03.04
    While loops and loop control

    Repeat while a condition holds, prove that a loop can finish, and use break and continue carefully.

    4 min
  5. 03.05
    Loop drills and patterns

    Build fluency with nested loops, accumulators, prime tests, and formatted output by writing the classic loop exercises properly.

    4 min
  6. 03.06
    Comprehensions

    Build new collections with concise transformations and filters while keeping the rule readable.

    4 min
MODULE SELF-CHECK

Ready to move on?

Process a collection of records, handle a boundary value (first/last item, empty collection), and explain exactly why your loop terminates without infinite loops.

Open the module self-check