Grade 12 Information Technology unit 6
range(): where it starts, stops and steps
4 min · 2 past exam questions worked through
Parts of the lesson
Tap a part to play the lesson from there.
A 4-minute Temari video lesson on Grade 12 Information Technology unit 6: range(): where it starts, stops and steps. Free to watch, no account needed.
More on unit 6
The chapter's own page holds the rest of what Temari has on it, such as short notes and practice questions with their answers.
Open the unit 6 pageEverything the lesson says
The lesson's words, part by part. Tap a time to play the lesson from there.
0:00Introduction
In Python, a for loop with range counts for you. But range has one habit that trips students up: it never reaches the number you tell it to stop at. Learn its three forms, and you can write out any sequence without running the code.
0:17A for loop counts with range
First, the loop. A loop repeats a block of statements. A for loop takes each value of a sequence in turn. Here: for i in range five, colon. The print statement is indented under it, because Python uses indentation to mark the block.
Range gives the loop its numbers. With one number, range starts at zero, counts up by one, and stops before that number. So range five gives zero, one, two, three, four. That is five values, but never five itself.
0:53Two numbers: a start
Give range two numbers, and the first one is the start. Range two, five starts at two and stops before five: two, three, four. The start is included. The stop is not.
A quick check: how many numbers? Take the stop minus the start. Five minus two is three, and there are three numbers. For range five, the start is zero: five minus zero is five numbers.
1:23Practice question 1Past exam
Here is a practice question. What sequence of numbers is generated by the Python expression, range(5)? Pause the video, and try it.
With one number, range starts at zero, and it stops before five. So: zero, one, two, three, four. The answer is C. A goes one step too far, to five. B starts at one, but the start is zero. And D also starts at one, so it loses the zero.
2:00Three numbers: a step
Now give range three numbers. The third is the step: how much it adds each time. Range one, ten, two starts at one and adds two each time: one, three, five, seven, nine.
The next number would be eleven. But the stop is ten, and the loop never goes past the stop. So the list ends at nine. Range ten, one hundred, ten would give ten, twenty, and so on up to ninety.
2:34Practice question 2Past exam
Try this one. What list of numbers is generated by the function, range(1, 10, 2)? Pause, and try it.
Start at one. Add two each time: one, three, five, seven, nine. Eleven would be next, but the stop is ten, so the list ends at nine. The answer is B. A forgets the step, and reaches the stop. C starts at two, but the start is one. And D runs on to eleven, past the stop.
3:12Summary
So remember. Range always stops before the stop number. With one number, it starts at zero. With two, the first one is the start. With three, the third one is the step. Keep practising questions like these on Temari.et.
Practise this unit in the app
Temari turns this chapter into timed practice and marks it as you go, with an AI tutor to explain anything that did not land.
Start freeTemari.et is also an Android app, free on Google Play.

