New
New
Year 10
OCR

While loops

I can use iteration controlled by a condition to repeat sequences of code.

New
New
Year 10
OCR

While loops

I can use iteration controlled by a condition to repeat sequences of code.

These resources will be removed by end of Summer Term 2025.

Switch to our new teaching resources now - designed by teachers and leading subject experts, and tested in classrooms.

These resources were created for remote use during the pandemic and are not designed for classroom teaching.

Lesson details

Key learning points

  1. Computer programs use iteration to repeat sequences of instructions.
  2. Iteration can be controlled by a condition that determines if the instructions should be repeated.
  3. In Python, condition-controlled iteration is implemented using the 'while' loop command.

Keywords

  • Iteration - the process of repeating a sequence of instructions within a program loop

  • Condition - an expression that evaluates to True or False

Common misconception

A loop will always run at least once.

A loop only runs if the condition allows it. If the condition isn’t met initially, the code inside won’t run at all.


To help you plan your year 10 computer science lesson on: While loops, download all teaching resources for free and adapt to suit your pupils' needs...

Demonstrate a loop with a condition that is False from the start and ask students to predict the output. It helps pupils to develop their understanding regardless of if their prediction was correct or not.
Teacher tip

Equipment

Code in this lesson is made using Python. Code examples use the RPF Code Editor but any Python IDE is suitable.

Licence

This content is © Oak National Academy Limited (2025), licensed on Open Government Licence version 3.0 except where otherwise stated. See Oak's terms & conditions (Collection 2).

Lesson video

Loading...

6 Questions

Q1.
What Python function is used to receive data that the user enters?
Correct Answer: input(), input
Q2.
Which of these is a logical operator in Python?
Correct answer: `and`
print
float
input
Q3.
What does the
print
function do?
receives user input
Correct answer: displays output
ends a program
compares values
Q4.
What does the operator
!=
mean?
equals
greater than
Correct answer: not equals
less than or equal to
Q5.
What is the purpose of the
if
statement?
Correct answer: to make decisions
to repeat code
to receive input
to display output
Q6.
Match the examples to their descriptions.
Correct Answer:`5 != 3`,True
5 != 3
- 

True

Correct Answer:`int()`,whole number data type
int()
- 

whole number data type

Correct Answer:`float()`,decimal number data type
float()
- 

decimal number data type

Correct Answer:`if`,decision-making statement
if
- 

decision-making statement

6 Questions

Q1.
What Python command is used for condition-controlled iteration?
Correct Answer: while(), while
Q2.
What is iteration in programming?
a process of storing data
writing a new program
comparing two values
Correct answer: repeating a sequence of instructions
Q3.
What does a condition in a while loop do?
stops the program from running
Correct answer: decides if the loop should continue
creates new instructions
deletes old code
Q4.
What happens if the condition in a while loop is False initially?
Correct answer: the loop doesn’t run at all
the loop runs once
the loop runs forever
the program crashes
Q5.
Order the steps of a condition-controlled loop.
1 - the condition is checked
2 - if True, the instructions run
3 - the condition is checked again
4 - if False, the loop ends
Q6.
Write the code to create iteration that will run if the variable num is over 5.
Correct Answer: while num > 5:, while num>5: