Single lesson · Key Stage 3

Count-controlled loops (for) – Year 8 Computing lesson

Pupils learn to write a for loop with range() that repeats a fixed number of times, and increment a counter inside a loop.

Also in a bundle Python: Iteration and Boolean Operators – Year 8 Computing lessons 6 lessons for £20 · save 16% on buying separately

Lesson 3 of 6 in unit 8.1 Python: Iteration and Boolean Operators, taught in Year 8, Autumn 1. It answers one big question: How can a program repeat something a fixed number of times?

By the end, pupils can write a for loop with range() that repeats a fixed number of times, and increment a counter inside a loop.

The Build (the main task)
Write a program that uses a for loop to look at every character of a password, increments a counter for each digit, then prints how many digits it has.
Support version
Part-filled code: the loop line and the counter are given; pupils fill in the if test and the increment line.
Challenge
Count capital letters as well, then print 'Add a digit' if the password has none.
Real-world link
A password checker has to look at every character to count the digits; a login screen gives you exactly three tries. Both repeat a fixed number of times.
Key words
Count-controlled loop, Increment and Fixed, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“range(1, 5) counts 1, 2, 3, 4 and 5”; “count = 1 adds 1 to count”.
National Curriculum
NC3 (two or more languages, at least one textual; data structures; modular programs with procedures or functions).

Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.

Pupils need computers for the main task.

Also sold in the Python
Iteration and Boolean Operators unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.

What's included

  • Slide deck (PowerPoint)
  • Lesson plan (Word)
  • Worksheet (Word)
  • Support worksheet with scaffolds (Word)
  • Single-teacher licence: use and adapt it with your own classes

More for KS3 Computing

See all

Written for the specifications named. Not endorsed by or affiliated with any exam board.