Year 5 (ages 9–10, Grade 4 in the US) · Computing · Selection · Lesson 2
if...then...else
if...then...else selection: two paths, tracing with true, false and boundary inputs, flowcharts and debugging.
Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

14-minute video lesson
Teaching, worked examples and 20 practice questions solved step by step.
Watch free for a monthWhat your child will learn
- Use if...then...else
- Trace two-path programs
- Test boundary values
- Draw if/else flowcharts
The method
- Condition.
- Then.
- Else.
- Test.
Key words: if then else, selection, condition, boundary, bug, trace.
Worked examples
Worked examples from the lesson, with every step.
Question 1
Trace: the user types ‘Paris’. What does the sprite say?
- Step 1: true
Answer: Correct!
Question 2
Trace: the user types ‘paris’ (small p). In many programs it still counts. But what if the program checks capitals exactly?
- Step 1: exact
Answer: it would go to ‘else’ - so test carefully
Question 3
Which part runs when the condition is false?
- Step 1: else
Answer: the else part