Session 5 - Loops with If...Only
To use conditions inside loops to change the behaviour of a program
Using
if
..else if
andelse
Lesson guide
Explain that in all programming languages, there is a way of asking a question and telling the computer what to do, depending on the answer. This is the
if… do..
. statement: if it is raining do put your coat on. If it is sunny do put on sun cream. Ask the children to come up with their examples.Video about conditions https://www.codeforlife.education/rapidrouter/33/
Draw pupils’ attention to the Level 33 instructions
Demonstrate level 33 on the IWB
Drag the repeat block and the if... do... block into the workspace.
6. Why do we need to put the if statement inside the repeat until at destination
loop? (Otherwise, the computer will only ask the question once and after one move forward
, the van would stop).
7. What happens if there is a turn in the road? Look at level 34. Show instructions
8. What instruction would we need to add? another if - demonstrate
Paired Activity
Pupils complete levels 33 - 35 in pairs
When the majority have finished, move on
If necessary, develop a solution to level 35 on the IWB
Discuss the suggested solutions to levels 34 and 35.
The suggested solution to level 34 doesn't work, the if blocks must be inside a loop.
The suggested solution to level 35 does work but the questions are in an illogical order. There are more forwards than anything else. The same number of blocks of code are run. This leads us on to the next topic of if..else if..else loops.
if..else if..else conditions
Show the video https://www.youtube.com/watch?v=GUUJSRuAyU0 it is also the introduction to level 36
Click the gear again to close the mini window.
Ask pupils to try levels 36 - 38
Share and Review
Explain that next time you are going to recap and test what they’ve learned.
What did pupils find difficult?
How did they solve their problems?
Recap on the keywords
Last updated