If, then, else
Answers are for parents and teachers.
1
Write three if … then … else sentences about your day. Underline the condition and circle the ‘else’ part.
Answers vary, for example: If it is sunny, then we play outside, else we play indoors.
2
A variable called pick is set to a random number from 1 to 3. The program says ‘Yes!’ if pick = 2, and ‘No’ otherwise. What can it say, and how often is it ‘Yes!’? Roll a die and use 1–2 for 1, 3–4 for 2 and 5–6 for 3 to test it 12 times.
It says Yes! when pick is 2 and No when pick is 1 or 3. Over many rolls ‘Yes!’ happens about one time in three.
3
True or false? (a) 15 = 15, (b) 3 + 4 = 8, (c) 20 = 2 × 10, (d) cat = hat
(a) true, (b) false, (c) true, (d) false
4
Draw a micro:bit with a 5 × 5 grid and show a happy face with the lights.
One pattern is 00000, 01010, 00000, 10001, 01110.
5
Explain to a grown-up what the ‘else’ part of an if … then … else block does, using an example.
It runs when the condition is false, for example: if it is raining, take an umbrella, else wear a hat.