Session 5 - Loops with If...Only

  • To use conditions inside loops to change the behaviour of a program

  • Using if..else if and else

Lesson guide

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

  2. Draw pupils’ attention to the Level 33 instructions

  3. Demonstrate level 33 on the IWB

  4. 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

  1. Pupils complete levels 33 - 35 in pairs

  2. When the majority have finished, move on

  3. 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

  1. Show the video https://www.youtube.com/watch?v=GUUJSRuAyU0 it is also the introduction to level 36

  2. Click the gear again to close the mini window.

  3. Ask pupils to try levels 36 - 38

Share and Review

  1. Explain that next time you are going to recap and test what they’ve learned.

  2. What did pupils find difficult?

  3. How did they solve their problems?

  4. Recap on the keywords

Last updated

Logo

Rapid Router resources

KS1KS2KS3

Kurono resources

TeacherStudent

© Copyright 2023 Ocado Group plc. All rights reserved