icon-background-square
New
New
Year 8

Using selection

I can write selection statements that make decisions about which path a program will follow.

icon-background-square
New
New
Year 8

Using selection

I can write selection statements that make decisions about which path a program will follow.

warning

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.

Lesson details

Key learning points

  1. Selection is used when there is more than one possible path for a program to follow.
  2. Relational operators can be used to compare the values of expressions.
  3. Expressions formed using relational operators evaluate to either True or False.
  4. Logical expressions can be built using a combination of relational and logical operators.

Keywords

  • Relational operators - compare two values and produce the result of True or False

  • Condition - an expression that evaluates to True or False

  • Selection - used when there is more than one possible path for a program to follow

  • Logical expression - an expression that combines relational and logical operators

Common misconception

The = symbol is used to check if a variable is equal to a value (comparison).

The = symbol is used in Python for assignment. The == operator is used for comparison.


To help you plan your year 8 computing lesson on: Using selection, download all teaching resources for free and adapt to suit your pupils' needs...

This is the first time pupils will have experienced indentation in their Python programs. It is worth pointing out the auto indentation that The Raspberry Pi Foundation code editor provides and encourage pupils to check indentation is correct within selection statements.
speech-bubble
Teacher tip
equipment-required

Equipment

All pupils require access to devices that can edit and run Python programs. Starter code files are available to copy or use directly via the Raspberry Pi Code Editor.

copyright

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.
The data a variable holds can throughout the running of a program.
Correct answer: change
not change
Q2.
The
=
symbol in Python is used for...
Correct answer: assignment.
equations.
comparison.
Q3.
Which of the following is an example of a string?
100
True
3.14
Correct answer: `"Hello world!"`
Q4.
What name would be displayed when this Python program is run?
1234
name = "Izzy" name = "Lucas" name = "Izzy" print (name)
name
Correct answer: `Izzy`
Lucas
Q5.
What is the result of the following Python expression?
1
10 + 5 * 2
Correct Answer: 20
Q6.
What function is used to convert user input from a string to an integer in Python?
input()
print()
Correct answer: `int(input())`
int()

5 Questions

Q1.
Write the Python code to store the number 25 in a variable called age.
Correct Answer: age = 25, Age = 25, age = int(25), age=25, Age=25
Q2.
In Python, which keyword allows you to create a block of code that only executes when a certain condition is true?
print
else
Correct answer: `if`
input
Q3.
In Python, which of the following code blocks demonstrates a correct way to use an if-else statement?
An image in a quiz
An image in a quiz
Correct Answer: An image in a quiz
An image in a quiz
Q4.
Which if statement would correctly check if the variable score is greater than or equal to 80?
Correct answer: `if score >= 80:`
if score > 80:
if score = 80:
if score <= 80:
Q5.
You are creating a program for a game where the player wins if they roll a 6 on a dice. Write the if statement that would check if the variable
dice_roll
is equal to 6.
Correct Answer: if dice_roll == 6:, if dice_roll==6: