Ohbot
  • OH
  • About
    • Our Story
    • Follow us
    • Contact
  • Buy
    • Ohbot
    • Picoh
    • Accessories
    • Compare Robots
    • Resellers
  • Get Started
    • Ohbot Kit
    • Ohbot Assembled
    • Picoh
    • Accessories
    • Technical Notes
    • Support
  • Learn
    • Block Programming
    • Python Programming >
      • Programming Ohbot
      • Programming Picoh
    • Share
<-Ohbot SCHEME

Year 5 - Lesson 2
​ (If-then)

Picture
Learning Intention
  • I can use the if-then instruction.

Picture
​Introduction
What did we learn to do last week? (use the current operator)  This week we will start with another task which uses current but we will combine this with another new piece of code, the if-then instruction.  What does if mean?  Can you put if into a sentence?  Collect the best ideas on a class working wall.  Where can we find the if-then instruction? (Control palette). What does the if-then instruction look like?  if-then is a conditional instruction, this means the condition has to go in the empty hexagon and the result goes in the middle of the two arms.

Picture
​Teacher Input 1
Ohbot can say the correct response for the time of day.  If it is before 12 noon Ohbot can say good morning and if it is after 12 noon Ohbot can say good afternoon.  We will now work together to write the code for these two if instructions.  We need to start our program with a when green flag clicked.  We will then need two if  instructions - one for if it is before 12 noon and one for if it is after 12 noon.  

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 a greater than (>) operator and a less than (<) operator.  If the hour is less than 12 the result is that we say ‘good morning’ and if the hour is greater than 12 the result is we say ‘good afternoon’.  File, Save As – ‘if hour’.
Picture
​We can take this further because Ohbot can ask you a question.  You can type an answer and then in turn Ohbot can respond to your answer.  For example, Ohbot can ask you your name and respond to the answer you type.  

To ask a question we need to go to the Sensing palette and use an ask and wait instruction.  Ohbot can reply by saying hello and using the response you typed in.  You need a join operator from the Operators palette and an answer variable from the Sensing palette.  File, Save As – ‘ask name’.
Picture
​We can take this even further by using the if-then instruction.  Ohbot can respond to your question with different answers depending on your response to the question.  For example, Ohbot can ask the question ‘are you a boy or a girl?’  Ohbot can respond appropriately depending on the answer you typed.  What would be an appropriate response if you typed girl? (You are female). What would be an appropriate response if you typed boy? (You are male.)

Activities
1. Can you write some code to ask the question are you a boy or girl and respond appropriately?
2. Can you write your own question for Ohbot to ask and respond to?
Picture
​Extension 1
You will need a dice. Can you write a program to make Ohbot ask the score when you throw it, and respond appropriately to each possible score?  Top tip - How many possible outcomes can you have with a dice? (6)  Therefore, how many if instructions will you need? 

Picture
​Extension 2
Can you edit your code?
Can you make Ohbot randomly generate an dice score between 1 and 6?

​Plenary
Which tasks were you successful at?  Show examples of children’s coding.  Which activity did you enjoy the most?  
Picture
OH

About
Ohbot Robots
Our Story
Follow us
Contact
Buy
Ohbot
Picoh
Accessories
​
Compare Robots
Order enquiries
Resellers


Get Started
​Assemble Ohbot Kit
Ohbot
Picoh
Ohbot Accessories
Technical Notes

Support

Learn
Block Programming
  Ohbot Python
  Picoh Python    Share
​
​Ohbot Ltd.
5 Halliday's Mill
London Road, Chalford
Gloucestershire, GL6 8NR, UK
Picture
Picture
Picture
Picture
Picture
Copyright © Ohbot Ltd.  All rights reserved.
​Ohbot
® is a registered trademark of Ohbot Ltd.
  • OH
  • About
    • Our Story
    • Follow us
    • Contact
  • Buy
    • Ohbot
    • Picoh
    • Accessories
    • Compare Robots
    • Resellers
  • Get Started
    • Ohbot Kit
    • Ohbot Assembled
    • Picoh
    • Accessories
    • Technical Notes
    • Support
  • Learn
    • Block Programming
    • Python Programming >
      • Programming Ohbot
      • Programming Picoh
    • Share