Nested selection and CASE – OCR GCSE Computer Science lesson (J277)
Pupils learn to write nested IF statements and a CASE statement (Python match) and choose which suits a problem with multiple options.
Lesson 8 of 14 in unit 10.2 Memory, Storage and Selection, taught in Year 10, Autumn 2. It answers one big question: How can a program handle many choices neatly?
By the end, pupils can write nested IF statements and a CASE statement (Python match) and choose which suits a problem with multiple options.
- The Build (the main task)
- Write a Python program that inputs an activity code (S, G or C) and uses a CASE statement (match) to set the price, then uses nested selection to take £1 off for members.
- Support version
- Part-filled code: the match line and the first case are written; pupils complete the other cases, the default case and the nested member discount.
- Challenge
- Rewrite the CASE statement as IF and ELIF, and explain when a CASE statement is the better choice.
- Real-world link
- The kiosk's activity menu: swim, gym or climbing wall, each with its own price, and a members' discount.
- Key words
- Nested selection, CASE statement and Multiple, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “The inner IF is still checked when the outer IF's condition is False”; “More than one case can run in a CASE statement”.
- OCR J277 specification
- 2.2.1 (programming fundamentals: selection (IF, ELSE IF, nested IF and CASE), comparison operators and Boolean operators AND, OR, NOT).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Pupils need computers for the main task.
Also sold in the Memory, Storage and Selection unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for GCSE Computer Science (OCR)
See allPupils learn to use algorithmic thinking, pattern recognition and logical checking to solve unfamiliar Bebras tasks, and choose which tasks to attempt first.
Free sample lessonPupils learn to take the 45-minute UK Bebras Challenge under test conditions, using abstraction, decomposition and a deliberate strategy to manage their time.
Free sample lessonPupils learn to explain why a computer needs primary storage close to the CPU, and why it is volatile and only holds data temporarily.
Free sample lessonWritten for the specifications named. Not endorsed by or affiliated with any exam board.