Lesson 9: My Loopy Robotic Friends Jr.
Building on the initial "My Robotic Friends" activity, students tackle larger and more complicated designs. In order to program their "robots" to complete these bigger designs, students will need to identify repeated patterns in their instructions that could be replaced with a loop.
This lesson serves as a reintroduction to loops, using the now familiar set of "robot" programming instructions. Students will develop critical thinking skills by looking for patterns of repetition in the movements of classmates and determining how to simplify those repeated patterns using loops.
Warm Up (10 min)
Activity (30 min)
Wrap Up (5 min)
Students will be able to:
- Identify repeated patterns in code that could be replaced with a loop
- Write instructions that use loops to repeat patterns
- Make sure each student has a journal.
- Prepare a stack of 20 paper cups (or paper trapezoids) for each group of 4 students.
- Display the symbols where students can reference throughout the lesson.
- (Optional) Print out one image pack per group of 4 students.
Heads Up! Please make a copy of any documents you plan to share with students.
For the Students
- My Robotic Friends - Cup Stacking Ideas
- My Robotic Friends - Cup Spacing
- My Robotic Friends - Symbol Key
- My Robotic Friends - Paper Trapezoid Template
- Loop - The action of doing something over and over again.
- Repeat - To do something again.
Warm Up (10 min)
My Robotic Friends Review
Goal: This review will refresh the students’ minds about how quickly programs for the "My Robotic Friends" activity can get intense.
Display: Show the My Robotic Friends - Symbol Key that we used in My Robotic Friends. For each of the four symbols, ask students to show you what it looks like for a robot to follow that instruction.
Model: With the class together as a group, pull an easy puzzle from the "My Robotic Friends" Cup Stack Pack and program with each other as a reminder of rules and terminology.
Next, pull a puzzle that’s slightly harder, but also requires a lot of steps like the one below.
Volunteer: Ask a volunteer (or a group of volunteers) to come forward to help program this one on the board. If you make them stick strictly to the “no symbols other than those on the key” rule, it will probably take a while!
Display: Now, bring up this image:
What is the reaction of the class?
Prompt: Give students the opportunity to brainstorm shorter ways to relay the code that they’re about to create. (This bit can be skipped over if your students start saying things like: “Move forward 6 times.” Since that will open the discussion about how to show “six times” with symbols.)
Once students have put together the idea of “repeating” code, give them the vocabulary around it. Make sure to share with them that often the terms “repeat something” and “loop something” are often used interchangeably.
Activity (30 min)
Introduction and Modeling
Set Up: Have stacks of cups or cut paper trapezoids available for groups.
Display: Take the program from one of your previous cup stacks and display it for the class, or use the one below.
Think: Ask students to think quietly about where in this program they can find a pattern of instructions that repeat uninterrupted (one repetition after another).
Pair: Turn to a neighbor and share one of the repeating patterns you found.
Share: Ask a few students to share out the patterns they identified. Try to pull out different approaches to grouping patterns. For each pattern, ask students to identify how many times the pattern repeats.
Model: Using one of the repeating patterns that the class identified, model how Circle the instruction or pattern that repeats, write the number of loops near that circle, then cross out the rest of the arrows.
Repeat this until the entire program has been shortened, then re-write the program in a way where students can see how much more simple the resulting instructions are.
Looping Your Robots
Group: Place students into groups of 4. Each group should then further break down into two pairs - each pair will develop their own program "run" on the other pair.
Distribute: Give each group one stack of cups or paper cutouts.
Display: Show My Robotic Friends - Cup Stacking Ideas to the class or hand out individual copies for groups to use. Have each pair (not group) choose which stack they would like their robot to do. Encourage pairs to select a more complicated pattern this time around.
Looking for Loops: Be sure to keep your eyes open for students using loops. Try to avoid correcting their overall algorithms or prescribing a solution, but feel free to direct students towards patterns that could be shortened by using a repeat circle.
Watch students as they run through the code. Are there any bugs? Use the debugging questions to help them find a solution.
- What does it do?
- What is it supposed to do?
- What does that tell you?
- Does it work at the first step?
- Does it work at the second step?
- Where does it stop working?
Discuss: Let each group discuss how the stack should be built, then instruct each group to translate the algorithm into symbols. Make sure each group writes down the symbol algorithm somewhere for the "robot" to read later. As students are working on their programs, remind them to be on the lookout for opportunities to replace a repeating pattern with a loop.
Do: When groups have finished their instructions, have each pair trade with another pair to run one another's code. Remind students to be on the lookout for bugs, but not to interrupt a robot until it's finished running the program.
Discuss: When all of the pairs have had a chance to run their programs, ask a few to share their solutions with the class. Use this opportunity to discuss how groups came up with different solutions to the same puzzle. In particular, you might ask of each program:
- How did they identify the loops?
- Are there other ways those loops could have been written?
- How much shorter is the program with loops than it would be without?
- Is the program easier to understand with loops, or written out longhand? Why?
Wrap Up (5 min)
- Draw one of the "Feeling FaceS" that shows how you felt about today's lesson in the corner of your journal page.
- Have the students write or draw something in their journal that will remind them later what loops are. This can come from a prompt like:
- What does "repeat" mean to you?
- Draw a picture of you repeating something.
- Have students draw their own cup stacking creations for someone else to code.
- Provide students with algorithms that utilize repeats, then have them expand the program back out to a full step-by-step version.
CSTA K-12 Computer Science Standards (2017)
AP - Algorithms & Programming
- 1A-AP-09 - Model the way programs store and manipulate data by using numbers or other symbols to represent information.
- 1A-AP-10 - Develop programs with sequences and simple loops, to express ideas or address a problem.
- 1A-AP-11 - Decompose (break down) the steps needed to solve a problem into a precise sequence of instructions.
- 1A-AP-14 - Debug (identify and fix) errors in an algorithm or program that includes sequences and simple loops.