← Python

range()

range() generates a sequence of integers, most often used with a for loop

What it does: range(start, stop, step) — starts at 2, counts by 2, stops before 8. Step of 2, stopping before 10 — so 10 is excluded. Stop is 0, which is excluded — count down stops at 1. range(1, 4) gives 1, 2, 3 — that's 3 numbers. Start at 1, add 3 each time: 1, 4, 7, then 10 is excluded. range() only accepts integer arguments. Using floats causes a TypeError. list() converts a range to a list. range(3) gives 0, 1, 2. Creates numbers from 0 up to but not including stop.

Common mistakes: range(1, 5) stops before 5: use range(1, 6) to include 5. To count down, you need a negative step: range(10, 0, -1).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does range(5) produce?
0, 1, 2, 3, 41, 2, 3, 4, 5
Matches
❌ range(1.5, 10)
Error: range() needs integers
Applying
Meanings
Term
range(stop)
Meaning
Creates numbers from 0 up to but not including stop.
Practice
for i in range(5):
Testing
Gaps
for i in (5):
Check Answer
Spots
2total = 0
3for i in range(1, 5):

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Scorpion' badge — Venom Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does range(5) produce?
A. 0, 1, 2, 3, 4 ✓
B. 1, 2, 3, 4, 5
range() starts at 0 by default and stops before the number given
2. What does range(2, 5) produce?
A. 2, 3, 4, 5
B. 2, 3, 4 ✓
range(start, stop) — the stop value is excluded
3. Is the stop value included in range()?
A. No it stops before it ✓
B. Yes always included
range(2, 5) gives 2, 3, 4 — it stops BEFORE 5
4. What does range(0, 10, 2) produce?
A. 0, 2, 4, 6, 8, 10
B. 0, 2, 4, 6, 8 ✓
Step of 2, stopping before 10 — so 10 is excluded
5. What does range(3, 0, -1) produce?
A. 3, 2, 1 ✓
B. 3, 2, 1, 0
Stop is 0, which is excluded — count down stops at 1

Match the Pairs

range(1.5, 10) Error: range() needs integers
for i in range(5, 1): print(i) Error: No output — step needed
range(2, 8, 2) Valid: 2, 4, 6
range(5, 0, -1) Ok: Counts down 5,4,3,2,1
print(list(range(3))) Output: [0, 1, 2]
print(list(range(1,6))) Output: [1, 2, 3, 4, 5]

Key Term

range(stop)
Creates numbers from 0 up to but not including stop.~~range(start, stop)

Fill in the Blanks

1. for i in range(5): print(i)
2. for i in range(1, 6): print(i) # prints 1,2,3,4,5
3. for i in range(0, 10, 2): print(i) # counts by 2
4. for i in range(5, 0, -1): print(i) # counts down
5. for i in range(1, 6): print(i) # starts at 1

Spot the Error

Question 1
A # Print numbers 1 to 5
B total = 0
C for i in range(1, 5):
D print(i)
E total += i
Line C — range(1, 5) stops before 5: use range(1, 6) to include 5
Question 2
A # Count down from 10 to 1
B for i in range(10, 0):
C print(i)
D print('Done!')
Line B — To count down, you need a negative step: range(10, 0, -1)
Question 3
A # Print integers 1 to 4
B for i in range(1.0, 5.0):
C print(i)
D print('Done!')
Line B — range() only works with integers: not floats like 1.0
Question 4
A total = 0
B for i in Range(5):
C total += i
D print('Sum:', total)
Line B — range is lowercase: Range is not a valid function
Question 5
A total = 0
B for i in range[5]:
C total += i
D print('Sum:', total)
Line B — range uses parentheses (), not square brackets []
For Teachers

Create a free class, add this module to a journey, and track who's stuck.

Create a free teacher account →

No credit card. No setup fee. Make a class and invite students in under three minutes.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?