lesson
A range has a precise stopping point
1 · Learn
A counted loop repeats an action for a defined sequence of values. In Python, range(4) supplies 0, 1, 2 and 3, excluding the stop value 4. The single-line example 'for n in range(4): print(n)' prints those four values in order.
Count iterations separately from the final value. A loop starting at zero can run four times even though its last value is three. In multi-line Python code, indentation identifies the loop body.
2 · Worked example
For range(2,5), the values are 2, 3 and 4. Changing the stop to 6 adds one more value, not an extra copy of every earlier value.
3 · Your turn
List the values of range(1,4). How many iterations occur?
Check your answer
1, 2 and 3; three iterations.
4 · Apply your learning
Predict and run three small range examples, recording starting value, stopping rule and iteration count.
Adult guidance and safety
Use an approved private interpreter, simulator or authoring tool with fictional data. Trace and predict before running. Never execute unknown downloaded code, inspect real credentials or use other people's private data. Working examples still need saved-project and assessment integration before release.
Open your writing and drawing pad
Write, draw or show your working. Use a mouse, pen or finger. This pad is not a submitted answer.
Not saved to your account. Download your drawing as PNG and your typed notes as TXT before leaving or refreshing. They are separate files. Do not enter private information.
Open a picture saved on this device to draw on it again. Opening replaces the drawing, but Undo can restore it. PNG only, up to 4 MB and 4096 × 4096 pixels. The picture stays in this browser; it is not uploaded. Paper lines in a saved picture become part of that picture.
Clear the drawing? Your typed notes will stay. You can undo this action.
Your pad is empty.
Open a UTF-8 TXT file from this device, up to 40 KB and 10,000 characters. It stays in this browser. Opening can be undone until you type again. Downloads keep a new copy; they do not change the file you opened.
Replace the notes on this page with the opened file? Download the current notes first if you want to keep them.
Typed notes are not submitted answers.
Check a calculation · Year 5 onward
Use this only when your teacher or adult allows a calculator for the task. Show your thinking first. It does not replace mental or written arithmetic and does not mark your lesson answer.
Powers, roots and trigonometry · Year 7 onward
Use only when the task allows a calculator. Choose one operation at a time and record your working. Trigonometry here always uses degrees (DEG), not radians. Inverse sine, cosine and tangent return an angle, not a reciprocal. Keep exact fractions and π in answers when requested.
Approximate numerical results use up to 12 significant digits. Inverse sine returns −90° to 90°, inverse cosine 0° to 180°, and inverse tangent −90° to 90°; these are principal values, not every possible solution of a trigonometric equation.
Practice this lesson
Lesson resources
Browse the available practice activities and worksheets for this lesson.
Interactive activity
Year 8 Computing learning routine
Practice activity. It does not change your saved quiz score.
Your progress