Community resourceWorksheet

1CP2-CT-3.3 For loops and range

Part 3 of 7 · 1CP2-CT-3 · Lists, iteration and subprograms

The count-controlled loop worksheet, reading range() precisely before writing loops with it.

Students will:

  • read the start, stop and step of a range correctly
  • predict the exact output of a for loop
  • explain why the stop value is not generated
  • construct a loop that repeats an exact number of times
  • use a loop to repeat processing, not only output

Inside: 7 explanation cells, 2 multiple-choice questions, 2 Python tasks, 2 fill-in-the-blanks cells and 2 written answers. 19 marks, about 45 minutes.

Series: 1CP2-CT-3 · Lists, iteration and subprograms, part 3 of 7.

Shared by Coding PathwayVerified teacher

  • 15 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 17 Aug 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

For loops and range

A count-controlled loop repeats a known number of times. In Python, for takes each value from a sequence. The range() function generates a sequence of integers for the loop to use.

This differs from the while loops you already know: while repeats while a condition is true; for is the clearer choice when the values or count are already known.

1. Read range(start, stop, step)

Range start, stop and step24681012range(2, 12, 2)start includedstop excludedstep controls the change between values

The start is included. The stop is excluded. The step is the change each time. Defaults are start 0 and step 1.

  • range(4) generates 0, 1, 2, 3.
  • range(2, 6) generates 2, 3, 4, 5.
  • range(2, 12, 2) generates 2, 4, 6, 8, 10.
Fill in the blanks3 marks
In range(start, stop, step), the gap 1 value is included, the gap 2 value is excluded, and gap 3 controls the change each time.
  • start
  • step
  • stop
  • value

2. Predict before running

Read the loop variable values and output without executing this listing.

for number in range(3, 9, 2):
    print(number)
Multiple choice1 mark

Which option is the exact output?

  • A`3`, `5`, `7`
  • B`3`, `5`, `7`, `9`
  • C`2`, `4`, `6`, `8`
  • D`3`, `4`, `5`, `6`, `7`, `8`
Written answer2 marks

Explain why the loop prints three values and does not print 9.

Refer to start, step and excluded stop.

Students type their answer here.

3. Construct a fixed count

Write a loop that prints the integers 1 to 5 inclusive, one per line. Store each current value in a loop variable named number.

To include 5, the excluded stop must be 6.

Coding task3 marks
# Use for and range to print 1 to 5 inclusive.

4. Repeat processing, not just output

A loop can update an accumulator, a variable that stores a running result. Start it before the loop, update it inside the loop, and use it after the loop.

total = 0
for value in range(1, 5):
    total = total + value
print(total)

The values 1, 2, 3 and 4 are added, so the final total is 10.

Fill in the blanks3 marks
The accumulator begins at gap 1. After adding 1 and 2 it holds gap 2. After all four values it holds gap 3.
  • 0
  • 1
  • 3
  • 4
  • 10

5. Independent application

Use for and range() to calculate the total of the even numbers from 2 to 10 inclusive. Store the running result in total and print only the final total.

The range must generate 2, 4, 6, 8 and 10. The program will be checked for the loop, the generated sequence's effect and the final value.

Coding task4 marks
# Calculate and print 2 + 4 + 6 + 8 + 10.
Multiple choice1 mark

Which loop is usually clearest when a program must repeat exactly ten times?

  • AA while loop with no update
  • BA for loop using range
  • CAn if statement
  • DA list deletion
Written answer2 marks

A programmer expects range(1, 5) to generate 1, 2, 3, 4, 5. Identify the misconception and correct the range.

The stop value is not included.

Students type their answer here.

Route forward

You can control repetition with generated numbers. Next you will iterate directly over every item in a one-dimensional list and use a trace table to follow changing state.