Year 8 · Computing · Python: loops · Lesson 2
While loops
Python while loops: conditions, comparison operators, tracing, infinite loops, input checking, and choosing between for and while.

20-minute video lesson
Teaching, worked examples and 20 practice questions solved step by step.
Watch free for a monthWhat your child will learn
- Explain condition-controlled loops
- Use comparison operators
- Trace a while loop
- Spot and fix infinite loops
- Choose between for and while loops
The method
- Write the starting value.
- Check the condition.
- If True, run the body and update.
- If False, stop.
Key words: while, condition, comparison operator, infinite loop, condition-controlled, trace, input.
Worked examples
The first three practice questions from the lesson, with every step.
Question 1
A while loop repeats while its condition is…?
- Step 1: True or False?
Answer: True
Question 2
What does != mean?
- Step 1: Not equal to
Answer: Not equal to
Question 3
What does == mean, and how is it different from = ?
- Step 1: == compares; = stores (assigns)
Answer: == checks if equal; = assigns a value