5th GRADE
LESSON 6: PROGRAMMING A LOOPY ROBOT
LESSON MISSION
ACTIVITY 1: WARM UPDiscussion ForumClass Day 1
Time to Complete: 5 Minutes
You have been coding for a few weeks now and I bet you have had to create some pretty long strings of code in your programming. How could you cut down on the amount of code you have to write but still create an algorithm that produces the same results?
Click on your teacher's name below to go to your Google Classroom Discussion Forum. Answer this question on the forum. Then respond to 2 other people by commenting on their post. Remember to stay on topic and be polite. You can disagree but be respectful. ACTIVITY 2: LEARNInstruction for Coding the Teacher Bot!Class Day 1
To begin with, you will each receive a number. Go to the following places in the room with your number. Put the top down to your computer before you go.
|
TOOL BOXTERMS TO KNOW
algorithm: a list of steps to finish a task
define: figure out the details of the problems that you are trying to solve loop: the action of doing something over and over again prepare: research, plan, and acquire materials for the activity you are about to do program: an algorithm that has been coded into something that can be run by a machine programming: the art of creating a program reflect: carefully think back on something with the intention of improving the outcome in the future repeat: to do something again try: attempt to do something |
When you get to your station, I will give each team a bag of supplies. Do not open these up until I tell you to!
Step 2: Activity 2 Packets
|
Time to Complete: 2 Minutes
|
Each person in the group may now get out the Activity 2 Packets from your supply bag. There will be one packet for each member in your group to have their own.
Each Activity 2 Packet should have the following supplies. If it does not, please raise your hand so that I can get missing supplies for you.
|
|
Step 3: Review of Teacher Bot Programming
|
Time to Complete: 5 Minutes
|
Now, let's review Teacher Bot Programming. Remember, the Teacher Bot is a robot that stacks cups. The Bot only understands numbers and the commands on your command card. Let's quickly review the commands to make sure you remember what the bot will do with each command.
Put your cup top side down on the table. follow each voice command as I give them. After each command, check to make sure that each person on your team has performed the motion correctly.
- Pick Up Cup
- Move Forward 1 Space
- Turn Cup Right 90 Degrees
- Move Backward 1 Space
- Turn Cup Left 90 Degrees
Now I will project a command without words. Perform each command after it is projected. After each command, check to make sure that each person on your team has performed the motion correctly.
|
Remember, when you code the Teacher Bot, the width of the cup is two steps and there is 1 step between the cup stack and where the robot will put down the first cup. Also remember, you are programming the Teacher Bot's actions for the cup. Each time the Teacher Bot puts down a cup, it automatically returns to hover right over the cup stack again.
|
Please put all the Activity 1 Supplies back in the Activity 1 Packet.
Put your packets back in the Team Bag.
Put your packets back in the Team Bag.
ACTIVITY 3: APPLY
Coding the Teacher Bot Backwards
Class Day 2
Step 1: Activity 3 Packets
|
Time to Complete: 2 Minutes
|
Now, you are going to apply what you know to a Teacher Bot algorithm to figure out our lesson's mission question. Each person in the group may now get out the Activity 3 Packets from your supply bag. There will be one packet for each member in your group to have their own.
Each Activity 3 Packet should have the following supplies. If it does not, please raise your hand so that I can get missing supplies for you.
|
|
Step 2 Reviewing the Diagrams
|
Time to Complete: 2 Minutes
|
Now let's go over the Packet Instructions and recall how the Programming applies.
Look at the Activity 3 Diagram 1 Card. Remember and note the following things:
|
Look at the Activity 3 Coding Grid Example Card. Remember and note the following things:
Example 1
Use one row on your grid sheet to write the code for one cup. For example: Write all the commands needed to program the robot to move the first cup on the top row of the Coding Grid. Write all the commands needed to program the robot to move the second cup on the second row of the Coding Grid. And so on and so on. Example 2
Remember you do not move over up, or down spaces when you make a 90 degree turn, so you may have multiple code commands in one space. Look at the example above on the first row of the grid. The first space has only one command in the space. The second space has 3 commands in the space, because you don’t move spaces during the turns. You don’t move a space until you put the cup down. |
Step 3: Writing the Algorithm
|
Time to Complete: 10 Minutes
|
Now, you are going to work backwards to try to figure out our essential question for today. Look at the Diagram 1 Card. The Teacher Bot stacked the cups in the following way. Each team member is now going to write the code that the Teacher Bot used to stack the cards in this way on their coding grid.
Select one team member to take out the bag of clear cups from the Team Bag. There should be 20 cups in the bag. That team member should act as the Teacher Bot as the rest of the team writes the code on their Coding Grids. As the Teacher Bot moves the first cup into the position that is on the diagram, the other team members need to write down each command the robot used to put down the cup on the first row of their grids. Then, the Teacher Bot should place the second cup down. Again, the rest of the team writes the code on their Coding Grids. As the Teacher Bot moves the second cup into the position that is on the diagram, the other team members need to write down each command the robot used to put down the cup on the second row of their grids. Continue this way until all of the cups are placed. After each cup is placed the team should review the row of commands they wrote for that cup. If anyone got something different, have the Bot do the movements for that cup again to determine who is correct. Work quickly, staying on task. You only have 10 minutes to complete this step.
Select one team member to take out the bag of clear cups from the Team Bag. There should be 20 cups in the bag. That team member should act as the Teacher Bot as the rest of the team writes the code on their Coding Grids. As the Teacher Bot moves the first cup into the position that is on the diagram, the other team members need to write down each command the robot used to put down the cup on the first row of their grids. Then, the Teacher Bot should place the second cup down. Again, the rest of the team writes the code on their Coding Grids. As the Teacher Bot moves the second cup into the position that is on the diagram, the other team members need to write down each command the robot used to put down the cup on the second row of their grids. Continue this way until all of the cups are placed. After each cup is placed the team should review the row of commands they wrote for that cup. If anyone got something different, have the Bot do the movements for that cup again to determine who is correct. Work quickly, staying on task. You only have 10 minutes to complete this step.
ACTIVITY 4: ANALYZE
ANALYZING YOUR TEACHER BOT ALGORITHM
Class Day 2
Step 1: Checking Your Algorithm
|
Time to Complete: 5 Minutes
|
You should have gotten the following algorithm on your Coding Grid. If you did not, look over the correct algorithm. Discuss your algorithm and the correct algorithm with your team. What did you do wrong? Correct your algorithm.
Step 2: Identifying Patterns
|
Time to Complete: 5 Minutes
|
When you look at the algorithm on your Coding Grid, what patterns do you see? Does anything repeat? Talk about this with your team. Go through the algorithm and circle any of the same commands that repeat.
What did you come up with? Look at the Coding Grid in the picture below. Your Coding Grid should look similar to this one.
Step 3: Applying Numbers
|
Time to Complete: 5 Minutes
|
Remember, the Teacher Bot understands the commands that we used, as well as numbers. How might I use numbers with the patterns I see in this algorithm to help me create a shorter algorithm? Remember, the shortened algorithm must command the Teacher Bot to create the same structure with the stacked cups as the longer one did.
Talk about this with your team. Be ready to share your ideas in whole group discussion. You may write your ideas on your Coding Grids. You will have 5 minutes to brainstorm ideas with your group. You do not have to rewrite the code. Just tell me how you would use numbers with the repeating patterns you circled to shorten the algorithm.
Talk about this with your team. Be ready to share your ideas in whole group discussion. You may write your ideas on your Coding Grids. You will have 5 minutes to brainstorm ideas with your group. You do not have to rewrite the code. Just tell me how you would use numbers with the repeating patterns you circled to shorten the algorithm.
What did you come up with? Look at the Coding Grid in the picture below. Your Coding Grid should look similar to this one.
So, because the Teacher Bot understands numbers, you can use one command and put the number of times it repeats by the command to shorten the amount of code you have to write. Look at the picture below.
Step 3: Analyzing Your Algorithm
|
Time to Complete: 5 Minutes
|
You significantly reduced the amount of coding you had to write by identifying patterns and applying numbers. In coding, the action of doing something over and over again is called a loop. Look at the shortened algorithm above again. Don't think about the steps this time. Think about the commands themselves. Are there any repeated commands in our shortened algorithm that we did not apply a number to? Take 2 minutes and look at the shortened algorithm with your team. Identify any repeated commands that we missed.
What did you come up with? Look at the Coding Grid in the picture below.
So, there were 3 lines where you had to turn 90 degrees to the right two times in a row. You can change this code from 2 coded symbols to the number 2 and one coding symbol. Even though this does not actually shorten the amount of code you write, because you are writing two things in both algorithms, it is good to remain consistent when using a number and a symbol to shorten algorithms.
So the rewritten code will look like this.
ACTIVITY 5: CREATE
The Amazing Race: Coding With Loops
Class Day 3
In Activity 4, you analyzed a Teacher Bot Program to learn how to write loops in a code in order to shorten an algorithm. Now, you will compete in the Amazing Race: Coding With Loops and write a program for the Teacher Bot using loops on your own.
This Amazing Race will have two challenges. The first team to successfully complete both challenges wins the Race. Even though there is only one team winner, every team must complete the race. Each team is about to receive the Challenge 1 Packet. Do not open the packet until I say go.
Both Challenge Packets will have all the supplies you need and an Instructions Card. The Instructions Card will have a list of supplies you should have in your Challenge packets. If you are missing supplies, please raise your hand and I will come and see what is missing and replace it.
You will see a stack of coding grids in each packet. Teams only have to complete 1 Coding Grid but you're given extra copies so that every team member can participate and teams can check each other. Follow the instructions on the Instruction Card. When you have completed the task, bring the person's card that recorded the agreed upon correct answer to me. If it is correct, I will give you Challenge 2. If it is not correct, I will simply shake my head no. You and your team members will need to find your mistake and correct the code. Remember, even though there is only one team winner, every team must complete the race.
You will see a stack of coding grids in each packet. Teams only have to complete 1 Coding Grid but you're given extra copies so that every team member can participate and teams can check each other. Follow the instructions on the Instruction Card. When you have completed the task, bring the person's card that recorded the agreed upon correct answer to me. If it is correct, I will give you Challenge 2. If it is not correct, I will simply shake my head no. You and your team members will need to find your mistake and correct the code. Remember, even though there is only one team winner, every team must complete the race.
Does everyone understand the instructions? Once I hand out the Challenge 1 Packets to everyone, I will tell everyone when they can open their packets and start by saying, On your mark. Get set. Go!
MISSION ACCOMPLISHED
Congratulations! You Accomplished Your Mission!
I can identify patterns in a coded program and use loops to help me create a shorter algorithm.