All topics

Python 2: decisions and loops

Learners make programs that choose between actions and repeat them until a task is done, and trace them by hand.

Outline

Who it is for: Learners who finished Python 1: first programs.

Real programs make choices and repeat tasks, such as checking a payment or counting stock. Learners who can write clear decisions and loops can automate simple tasks at work or at school. At the end, the learner can build a quiz or guessing game that checks input and keeps a running score.

Learners spend real time tracing and debugging, not only writing. These are the skills that people who lean on AI lose first, and they are what a programmer needs to judge any code.

AI policy: Builders may use AI only as a tutor (explain or give a hint, never the answer), with the teacher present, and only after they have shown the skill without it. Pioneers and adults may use AI after the checkpoint, and must test any code and explain it in their own words. The checkpoint is done without AI.

Planned lessons

  1. True and False, and comparison operators
  2. if and else: predict which branch runs
  3. elif for more than two choices
  4. and, or, and not
  5. Testing every branch with chosen inputs
  6. while loops and when they stop
  7. Tracing a loop by hand with a trace table
  8. for loops with range
  9. Counting, totals, and running sums
  10. Input checks: asking again until the answer is valid
  11. Debugging loops that never stop or stop too early
  12. A guessing game or quiz project

Teach it as

One sessionTrace a short if and while program on paper, then write a program that asks yes or no and repeats until the answer is valid, in one 2 hour class.
One dayMorning: True and False, comparisons, if, elif, and else, and testing each branch. Afternoon: while and for loops, running totals, and tracing a loop by hand.
One weekDay 1: True, False, comparisons, and if and else. Day 2: elif, and, or, not, and testing every branch. Day 3: while loops and tracing them. Day 4: for loops, totals, and input checks. Day 5 (Build and Show): checkpoint without AI (trace, predict, and fix a loop), then each pair shows a quiz or guessing game.

Know this first

Standards this follows

Videos to download

No videos listed yet.