Year 5 - Lesson 3
(If-then-else)

Learning Intention
- I can use the if-then-else instruction.

What did we learn to do last week? (ask and respond using if-then) This week we will continue with our work on ask and respond. However, we will combine this with a new piece of code - the if-then-else instruction. if-then-else is also a conditional instruction, the condition has to go in the empty hexagon and the result goes in one of the two pairs of arms.

Teacher Input 1
Ohbot can respond differently to a question using if-then-else. Would you like to come to the school disco? We will now work together to write the code. We need to start our program with a when green flag clicked. We will need an if-then-else conditional instruction. We need to go to the Operators palette to find a hexagonal shaped operator to help us build the condition. In this example we need an equals (=) symbol. If the answer is yes, we say one response else we say a different response. File, Save As – ‘ask disco’.
Activity
Ohbot can respond differently to a question using if-then-else. Would you like to come to the school disco? We will now work together to write the code. We need to start our program with a when green flag clicked. We will need an if-then-else conditional instruction. We need to go to the Operators palette to find a hexagonal shaped operator to help us build the condition. In this example we need an equals (=) symbol. If the answer is yes, we say one response else we say a different response. File, Save As – ‘ask disco’.
Activity
- Can you create your own if then else question for Ohbot to ask?

Teacher Input 2
We can take this one step further by adding a sound effect and some motion instructions to the code so that Ohbot’s response is even more appropriate e.g. a head nod for yes and a head shake for no. Sound effects can be found on the Sound palette - the drop down shows the list of wav format files stored in ThisPC>Music>Ohbot. Any files in wav format can be placed in this folder so that they can be used within the Ohbot software. The head nod and shake builds on our work in previous years.
Activity
2. Can you add sound and motion to your ask and respond question. File, Save As – ‘Ask and wait if then else’.
We can take this one step further by adding a sound effect and some motion instructions to the code so that Ohbot’s response is even more appropriate e.g. a head nod for yes and a head shake for no. Sound effects can be found on the Sound palette - the drop down shows the list of wav format files stored in ThisPC>Music>Ohbot. Any files in wav format can be placed in this folder so that they can be used within the Ohbot software. The head nod and shake builds on our work in previous years.
Activity
2. Can you add sound and motion to your ask and respond question. File, Save As – ‘Ask and wait if then else’.

Extension
Show the children the ask and respond joke code. Play them the program. What is different with this code? (Contains two ask and respond questions that follow on from each other.) Extension task - Can you write two ask and respond questions within one program? Can Ohbot also move and make a sound when it responds? You can use the joke idea or create your own series of questions.
Plenary
Which tasks were you successful at? Show examples of children’s coding. Which activity did you enjoy the most? How did you find today’s lesson?
Show the children the ask and respond joke code. Play them the program. What is different with this code? (Contains two ask and respond questions that follow on from each other.) Extension task - Can you write two ask and respond questions within one program? Can Ohbot also move and make a sound when it responds? You can use the joke idea or create your own series of questions.
Plenary
Which tasks were you successful at? Show examples of children’s coding. Which activity did you enjoy the most? How did you find today’s lesson?