GCSE · Computer Science · Edexcel · Spec 1CP2
Count-controlled repetition
Need to print a line of stars 50 times? Don't paste it 50 times. Write two lines and let a for loop do the counting.
Computer Science · Iteration
Watch count skip along
range(2, 11, 2) means: start at 2, stop at 11, go up in steps of 2. Press Next to run the loop one pass at a time and watch what count holds.
Before you press Next: how many times will this loop run — and will 11 ever be printed?
1 for count in range(2, 11, 2):2 print(count)3 print("Finished!")
| Pass | count |
|---|---|
| — | — |
Output
Step 1: Nothing has printed yet. First, range sets up the sequence the loop will walk along: 2, 4, 6, 8, 10. It's fixed before the first pass, so the loop already knows it will run 5 times. 11 isn't in the sequence. It's only where the counting stops.
Step through the trace — every value is the lesson’s, not run by the page.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
A for loop knows how many times it will run before it starts. It runs once for each value range gives it, then stops by itself.
What you need to know
- What iteration is, and what makes it count-controlled
- How a for loop uses range to decide how many times it repeats
- What range gives you with one, two or three numbers, and why the stop number is never included
- What the count variable holds on each pass, and when the loop ends
- How to make the number of repetitions come from a variable
The big picture
Iteration means repeating instructions in a loop, and when a count decides how many repeats there are, it's count-controlled. In Python that's a for loop: for every value in a sequence, it runs the indented block once. range generates the sequence. One number is the stop point (counting from 0), two are start and stop, and three are start, stop and step. The stop number is never included. On each pass the count variable holds the next value, and when the values run out the loop ends by itself. The number of passes can come from a variable, such as num_users.
Key points
Worked example
Problem
A running app should print Lap 1, Lap 2, Lap 3, Lap 4 and Lap 5. A student writes: for lap in range(1, 5): print("Lap", lap) What does it actually print, and how do you fix it?
⚠ Watch out
Reading the stop number as the last value. range(2, 11, 2) ends on 10, not 11, because the stop point is never part of the sequence.
Memory hook
Start, stop, step, and stop means stop BEFORE.
Check yourself
Without running it, how many times does for count in range(3, 9, 2): run, and what does print(count) output on each pass?
Flashcards
(13)What is iteration?
What makes iteration count-controlled?
Which Python loop is used for count-controlled iteration?
What does range do?
In range(start, stop, step), what does each number do?
What does range(5) generate?
Why isn't the stop number in the sequence?
What is the count variable?
When does a for loop end?
How many times does for count in range(3, 8): run?
How do you make a loop repeat once for every user?
Why use a loop instead of copying and pasting the same line?
Which range gives 10, 20, 30?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Edexcel GCSE Computer Science topics
How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 29 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.