icon-background-square
New
New
Year 10
AQA

Nested selection

I can trace and modify code in a program that uses nested selection.

icon-background-square
New
New
Year 10
AQA

Nested selection

I can trace and modify code in a program that uses nested selection.

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 statements with conditions can be nested inside another selection statement.
  2. Nested selection statements are used to implement complex branching logic.
  3. If a condition of a main selection block evaluates to True, it leads to sub-conditions which are inside the main block.

Keywords

  • Nested selection - A block of code where a selection block is placed within another selection block.

Common misconception

A nested selection statement can only have one nested selection block.

Selection statements can can continue to be nested in further selection blocks to provide more complex conditions for which specific code will be executed.


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

The second part of the lesson requires pupils to modify an existing program. Encourage learners to run the code a few times to investigate how it works before answering the questions.
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 expressions will return False?
Correct answer: 3 > 4
(3+10) < (3*10)
(5-2+10/2) == 8
Correct answer: (2+10) != (6*2)
Q2.
Which of these statements would return True for the following card?
An image in a quiz
Correct answer: value > 6
value != 10
Correct answer: value == 10
value <9
Q3.
The three logical operators are 'and', 'or' and ' '.
Correct Answer: not
Q4.
Logical operators can be used alongside relational operators to build logical when more values need to be compared.
Correct Answer: expressions, xpressions
Q5.
Which expressions would return True for this card?
An image in a quiz
value == "king" and suit == "hearts"
value == 9 and suit == "hearts"
Correct answer: value == 9 and suit == "diamonds"
Correct answer: value == "king" or suit == "diamonds"
Q6.
Arithmetic expressions evaluate to a number. Logical expressions evaluate to .
Yes or No
Correct answer: True or False
0 or 1

6 Questions

Q1.
What is nested selection in programming?
A type of loop that repeats a block of code.
A way to store multiple values in a list.
A selection statement with multiple branches.
Correct answer: A selection statement placed inside another selection statement.
Q2.
What does the
lower()
method do when used on a string in Python?
Converts all letters to uppercase.
Correct answer: Converts all letters to lowercase.
Checks if the string contains numbers.
Removes spaces from the string.
Q3.
In nested selection, if the outer condition is `False`, the inner condition will .
Correct answer: not execute.
execute.
cause an error.
Q4.
What would be displayed if the user enters "Jun" for the username?
An image in a quiz
Password:
Access granted
Correct answer: ...program closing
Q5.
What would be displayed if the user enters "Izzy" for the username and then "Dog1234" for the password?
An image in a quiz
Correct answer: Password: ...program closing
Password: Access granted
...program closing
Q6.
What would be displayed if the user enters "Izzy" for the username and then "Fish4321" for the password?
An image in a quiz
Correct answer: Password: Access granted
...program closing
Password: ...program closing