Decisions and loops

Blocks, selection with if, elif and match, Boolean operators, for and while loops and the patterns they make: the robot starts reacting to what its sensors say.

Module F2GCSE8 lessons

Start in the simulator
  1. F2.1 Blocks and indentation How Python groups lines: the colon and the indent.
  2. F2.2 Selection: if Relational operators, and a block that runs only when a condition is true.
  3. F2.3 else, elif and Boolean operators Choosing between outcomes, and joining conditions with and, or and not.
  4. F2.4 Nested selection and match Decisions inside decisions, and choosing by exact value with a case statement.
  5. F2.5 Count-controlled loops: for range, the loop variable, and repeating a known number of times.
  6. F2.6 Condition-controlled loops: while Looping until something changes, break, and loops that never end.
  7. F2.7 Loop patterns Running totals, counting, finding the largest, nested loops and trace tables.
  8. F2.8 Project: parking sensor A while loop, decisions and the buzzer: beep faster as the wall gets closer, and park.