Sequence 4 - Lesson 2: Picoh Poet
Learning Intention
- I can use a list in a program
Introduction
What new skill did we learn last week? (We used the mouse, to allow a human to control Picoh and simulate Picoh’s response.) What is this type of Robotics called? (“Wizard of Oz” robotics.) This week we will be learning another new skill, to incorporate a list into a program. What is a list?
What new skill did we learn last week? (We used the mouse, to allow a human to control Picoh and simulate Picoh’s response.) What is this type of Robotics called? (“Wizard of Oz” robotics.) This week we will be learning another new skill, to incorporate a list into a program. What is a list?
Teacher Input 1
First, we are going to learn how to make a list and then how to input items into the list. There are several different ways you can input items into a list. Together we will use a variety of methods to add items to a list. Method one, adds one name at a time using some simple code. First, demonstrate how to create a list using Data, Make a List. Remember to add the tick so you can watch the list being created. Together, write a simple program using the code add thing to list.
First, we are going to learn how to make a list and then how to input items into the list. There are several different ways you can input items into a list. Together we will use a variety of methods to add items to a list. Method one, adds one name at a time using some simple code. First, demonstrate how to create a list using Data, Make a List. Remember to add the tick so you can watch the list being created. Together, write a simple program using the code add thing to list.
Next, demonstrate method two, how to add an item to the list using the ask command.
Activity
1. Can you write a program that makes Picoh ask four children to type in their names, adds the names to a list then selects one at random to win a special prize?
1. Can you write a program that makes Picoh ask four children to type in their names, adds the names to a list then selects one at random to win a special prize?
Teacher Input 2
Next, we will learn another way of adding items into a list, it is very simple just type the names in, separated by the pipe symbol |. Check all children can find the pipe | on the keyboard. (bottom left, next to z) This is very useful if you are making multiple lists or very long lists.
Next, we will learn another way of adding items into a list, it is very simple just type the names in, separated by the pipe symbol |. Check all children can find the pipe | on the keyboard. (bottom left, next to z) This is very useful if you are making multiple lists or very long lists.
Now we can create some projects that use a greater number of items in a list. For example, Picoh can make up a simple poem by randomly generating items in a list. Ask the children to create a list of animals. Next, ask them to create a list of adjectives to describe the animals. With some simple code we can generate a two word poem.
Activity 2
Can you write code to make Picoh say a simple poem by accessing three or more lists? Think of all the word games/word work activities you have completed in busy work/word work/starters.
Can you write code to make Picoh say a simple poem by accessing three or more lists? Think of all the word games/word work activities you have completed in busy work/word work/starters.
Teacher Input 3
Next, we will develop our list projects further by adding an if command to the code. We are going to create a project called favourite fruit. Picoh will ask the user what their 3/4 favourite fruits are and then say the answers out loud in turn. Picoh can then respond depending on if the condition is met e.g. if the list contains apples, say “I love apples too.” else say “I can’t believe apples are not one of your favourite fruits!” Demonstrate how to use the hexagonal contains inside the if command. E.g. if fruit contains apple.
Next, we will develop our list projects further by adding an if command to the code. We are going to create a project called favourite fruit. Picoh will ask the user what their 3/4 favourite fruits are and then say the answers out loud in turn. Picoh can then respond depending on if the condition is met e.g. if the list contains apples, say “I love apples too.” else say “I can’t believe apples are not one of your favourite fruits!” Demonstrate how to use the hexagonal contains inside the if command. E.g. if fruit contains apple.
Activity 3
Can you write a program to make Picoh ask for three favourite fruits and then read the list out loud? Followed by an if command for Picoh to respond if its favourite fruit (whatever that might be) appears on the list?
Extension
Can you write a program to make Picoh react if all three of its three favourite fruits appear in the list? This can be done using two AND operator blocks.
Plenary
Take a look at the children’s projects. Were you able to successfully write the code?
Can you write a program to make Picoh ask for three favourite fruits and then read the list out loud? Followed by an if command for Picoh to respond if its favourite fruit (whatever that might be) appears on the list?
Extension
Can you write a program to make Picoh react if all three of its three favourite fruits appear in the list? This can be done using two AND operator blocks.
Plenary
Take a look at the children’s projects. Were you able to successfully write the code?