Year 10 (ages 14–15, Grade 9 in the US) · Computing · GCSE programming · Lesson 3
Selection: if, elif and else
Making decisions in Python with if, elif and else, comparison operators, Boolean operators (and, or, not), indentation, and nested selection.
Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

8-minute video lesson
Teaching, worked examples and 20 practice questions solved step by step.
Watch free for a monthWhat your child will learn
- Use comparison operators
- Write if, elif and else statements
- Combine conditions with and, or, not
- Trace nested selection
The method
- A condition is True or False.
- if → elif → else: first True branch runs, then stop.
- Indent the code inside each branch.
- and: both True; or: at least one True; not: reverses.
Key words: selection, condition, comparison operator, Boolean operator, indentation.
Worked examples
Worked examples from the lesson, with every step.
Question 1
What is output when temp = 25? c:if temp > 30: c: print("Hot") c:elif temp > 20: c: print("Warm") c:else: c: print("Cool")
- Step 1: 25 > 30? False
- Step 2: 25 > 20? True → Warm
Answer: Warm
Question 2
Same program: what is output when temp = 30?
- Step 1: 30 > 30? False
- Step 2: 30 > 20? True
Answer: Warm
Question 3
Evaluate: (5 > 3) and (2 > 4)
- Step 1: True and False
- Step 2: Both must be True
Answer: False