icon-background-square
New
New
Year 8

Selection with multiple paths

I can write selection statements to provide three or more paths to follow within a program.

icon-background-square
New
New
Year 8

Selection with multiple paths

I can write selection statements to provide three or more paths to follow within a program.

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. Multi-path selection checks successive conditions and selects one out of multiple paths to follow.
  2. Selection statements with conditions can be nested inside each other.
  3. If selection statements are nested then code blocks must be indented.

Keywords

  • Condition - an expression that evaluates to True or False

  • Multi-path selection - selection when there is more than one path for a program to follow

  • Nested - a block of code where a loop is contained within another loop

Common misconception

An if statement can only have two options.

An if statement can be paired with elif and else statements to create multi-path selection. This allows for multiple paths to follow in a program.


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

With nested selection learners may get confused about the levels of indentation. It is worth pointing out the auto indentation that The Raspberry Pi Foundation code editor provides and encouraging pupils to check that the 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.
Which of the following Python expressions evaluates to
True
?
Correct answer: `10 > 5`
apple
==
banana
3 + 2 < 3 - 2
10 <= 5
Q2.
Which Python code is used to create a block of code that will run based on whether something is True or False?
print
else
Correct answer: `if`
input
Q3.
What is the output when the program is run?
12345
score = 7 if score > 5: print("score is greater than 5") else: print("score is not greater than 5")
Correct answer: score is greater than 5
score is not greater than 5
Q4.
Which logical operator in Python checks if two conditions are both True?
not
or
Correct answer: `and`
=
Q5.
What will be the output of this Python code?
1234567
is_raining = True is_cold = False if is_raining or is_cold: print("Stay indoors") else: print("You can go outside!")
You can go outside!
Correct answer: Stay indoors.
An error message.
No output will be produced.
Q6.
Arrange the following components of an if-else statement in the correct order.
1 -
if
2 - condition:
3 - code to execute if the condition is True
4 -
else:
5 - code to execute if the condition is False

6 Questions

Q1.
Which of the following statements accurately describes multi-path selection in Python?
Correct answer: You can have more than two options for your code to choose from.
Correct answer: The computer checks each condition in order.
All the code inside every
if
,
elif
, and
else
block runs.
Correct answer: It helps your program make different choices based on what's True.
Q2.
In Python, what is used to introduce an additional condition in a multi-path selection statement after an initial if statement?
if
Correct answer: `elif`
while
==
Q3.
What will be the output of the following Python code?
12345678910
grade = 75 if grade >= 90: print("A") elif grade >= 80: print("B") elif grade >= 70: print("C") else: print("Fail")
A
B
Correct answer: C
Fail
Q4.
What is the primary purpose of indentation in Python code, especially in the context of
if
,
elif
, and
else
statements?
to make the code look visually appealing.
Correct answer: to indicate which lines of code belong to which block or path of the selection.
to specify the order in which the conditions should be evaluated.
to define the data types of variables used in the conditions.
Q5.
Which of the following is correct when describing nested if statements?
Correct answer: The first condition needs to be True before the next condition can be run.
The first condition needs to be False before the next condition can be run.
Q6.
A game gives points based on a dice roll: Roll 1 or 2: lose a point. Roll 3, 4, or 5: no change. Roll 6: win a point. Which Python code is best for this?
single
if
if-else
Correct answer: `if-elif-else`