Selection with if and else – Year 7 Computing lesson
Pupils learn to write an if/else statement with a True or False condition, so a program gives a different outcome for different inputs.
Lesson 4 of 6 in unit 7.6 Introduction to Python, taught in Year 7, Summer 2. It answers one big question: How can a program choose what to do next?
By the end, pupils can write an if/else statement with a True or False condition, so a program gives a different outcome for different inputs.
- The Build (the main task)
- Write a program that asks how many people the recipe is for and uses if/else to tell the cook which bowl to use: the large bowl for more than 8 people, otherwise the small bowl.
- Support version
- Parsons problem: the lines are jumbled, with one extra line that has a missing colon, for pupils to order, indent and cross out.
- Challenge
- Explain what the program outputs for exactly 8 people, and why.
- Real-world link
- The recipe helper tells the cook which mixing bowl to use for the number of people.
- Key words
- IF statement, Condition and Outcome, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “Both the if part and the else part run, one after the other”; “Indentation just makes code look neat; Python ignores it”.
- National Curriculum
- NC3 (two or more languages, at least one textual; data structures; modular programs with procedures or functions); NC4 (boolean logic (AND, OR, NOT) in circuits and programming; binary numbers, addition and conversion).
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 Introduction to Python 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 KS3 Computing
See allPupils learn to write and run a Python program that uses print to output text, and fix syntax errors by reading the error message.
Free sample lessonPupils learn to use input to ask the user a question, store the answer in a variable by assignment and use a constant for a value that never changes.
Pupils learn to choose the right data type for a value, convert input to a number and use arithmetic operators to calculate the ingredients for a scaled recipe.
Written for the specifications named. Not endorsed by or affiliated with any exam board.