Book a free demo

๐Ÿ’ก Interactive lessons ยท free, no sign-up

For loops, and what range() really gives

Play Python For Loops and range()

Loading Python For Loops and range()โ€ฆ

Change start, stop and step and watch which numbers the loop uses. Learn why the stop value is left out.

ShareWhatsApp

How to play Python For Loops and range()

  1. Read the first step: range makes the numbers a loop goes through.
  2. Move the sliders and switches to change the diagram and watch what happens. The readout under the picture shows the numbers.
  3. Answer each question. If you are wrong you get a hint and can try again, with no penalty.
  4. Some steps ask you to make something happen, such as hitting a target value. Experiment until it works.
  5. Finish the lesson to earn XP and see how many questions you got right first time.

Tips and strategy

  • Do not rush. The controls are there to be played with, so try extreme values as well as sensible ones.
  • Say what you notice out loud or write it down before you press Continue.
  • Use the hint when you are stuck, and then try to explain the answer in your own words.
  • Write out the first few numbers by hand, then ask where the loop stops.

Keep playing

More games you might like

All 116 games โ†’

FAQ

Python For Loops and range(): questions

What does range(1, 6) give?

The numbers 1, 2, 3, 4, 5. It starts at 1 and stops before 6.

Why is the stop value not included?

range counts how many steps to take from the start, and it stops before reaching stop. This makes range(n) give exactly n numbers starting from 0.

What does the step do?

It sets how much to add each time. range(0, 10, 2) goes up in twos.

What age is this lesson for?

It suits ages 10 to 16 as a first step in Python loops.

Start a conversation

Questions about classes?

A parent or guardian can share the learner's age, level and goals, and we'll suggest a starting point and confirm the format before anything is booked.

  • Tell us the learnerโ€™s age or grade and goals
  • Weโ€™ll suggest a suitable class or learning path
  • Weโ€™ll confirm format, timing and fees with a parent or guardian

For a childโ€™s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

Weโ€™ll use your details only to respond to this request.

Chat on WhatsApp
Esc

Try