Skip to content

Year 8 · Computing · Python: loops · Lesson 1

For loops

Python for loops: iteration, range with start, stop and step, the loop variable, the colon and indentation.

Whiteboard video lesson: For loops

19-minute video lesson

Teaching, worked examples and 20 practice questions solved step by step.

Watch free for a month

What your child will learn

  • Explain iteration
  • Use range with one, two and three numbers
  • Predict the output of a for loop
  • Use indentation correctly
  • Write for loops

The method

  1. Find the range: start, stop, step.
  2. List the loop variable's values.
  3. Run the indented lines for each value.
  4. Run unindented lines once after.

Key words: loop, iteration, for, range, indentation, variable, count-controlled.

Worked examples

The first three practice questions from the lesson, with every step.

Question 1

What is iteration?

  1. Step 1: Repeating code

Answer: Repeating code using a loop

Question 2

How many times does for i in range(4) repeat?

  1. Step 1: 0, 1, 2, 3

Answer: 4 times

Question 3

What values does range(3) give?

  1. Step 1: Start 0, stop before 3

Answer: 0, 1, 2