Skip to content
Menu

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.

Whiteboard video lesson: if...then...else

14-minute video lesson

Teaching, worked examples and 20 practice questions solved step by step.

Watch free for a month

What your child will learn

  • Use if...then...else
  • Trace two-path programs
  • Test boundary values
  • Draw if/else flowcharts

The method

  1. Condition.
  2. Then.
  3. Else.
  4. 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?

  1. 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?

  1. Step 1: exact

Answer: it would go to ‘else’ - so test carefully

Question 3

Which part runs when the condition is false?

  1. Step 1: else

Answer: the else part