Lesson 6: My Loopy Robotic Friends

Overview

Building on the initial "My Robotic Friends" activity, students learn to use loops when programming their robots in order to build bigger structures more efficiently.

Purpose

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.

Agenda

Warm Up (10 min)

Activity (30 min)

Wrap Up (5 min)

Extension Activities

View on Code Studio

Objectives

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

Preparation

OR

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Teachers

For the Students

Vocabulary

  • Loop - The action of doing something over and over again.
  • Program - An algorithm that has been coded into something that can be run by a machine.
  • Programming - The art of creating a program.
  • Repeat - To do something again.

Support

Report a Bug

Teaching Guide

Warm Up (10 min)

My Robotic Friends Review

Robot Symbols

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 six 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 together 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 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.

3 cup solution

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.

looped code

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 for the other pair to "run".

Distribute: Give each group one stack of cups or paper cutouts.

Display: Show Stacking Cup Ideas - Manipulatives to the class or hand out individual copies for groups to use. Have each pair (not group) choose which idea they would like their robot to do. Encourage pairs to select a more complicated pattern this time around.

Teaching Tip

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 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 the symbols. Make sure each group writes down the program 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 take turns "running" their code with another pair. Remind students to be on the lookout for bugs in their code, 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)

Flash Chat / Journaling

Having students write about what they learned, why it’s useful, and how they feel about it can help solidify any knowledge they obtained today and help to build a review sheet for them to look at in the future.

Flash Chat:

Here are some possible topics:

  • Do you feel like loops make programming easier or harder?
  • What other kinds of things in life do we repeat?

    • Eating - put food in mouth, chew 20 times
    • Brushing hair - brush through hair 35 times
    • Routines - Wake up, go to school, come home, go to bed
  • Write or draw something in your journal that will remind you later what loops are.

    • What does "repeat" mean to you?
    • Draw a picture of you repeating something.

Extension Activities

  • 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.

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 1B-AP-11 - Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.

Cross-curricular Opportunities

This list represents opportunities in this lesson to support standards in other content areas.

Common Core English Language Arts Standards

L - Language
  • 4.L.6 - Acquire and use accurately grade-appropriate general academic and domain-specific words and phrases, including those that signal precise actions, emotions, or states of being (e.g., quizzed, whined, stammered) and that are basic to a particular topic (e.g
SL - Speaking & Listening
  • 4.SL.1 - Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 4 topics and texts, building on others’ ideas and expressing their own clearly.
  • 4.SL.1.a - Come to discussions prepared, having read or studied required material; explicitly draw on that preparation and other information known about the topic to explore ideas under discussion.
  • 4.SL.4 - Report on a topic or text, tell a story, or recount an experience in an organized manner, using appropriate facts and relevant, descriptive details to support main ideas or themes; speak clearly at an understandable pace.
  • 4.SL.6 - Differentiate between contexts that call for formal English (e.g., presenting ideas) and situations where informal discourse is appropriate (e.g., small-group discussion); use formal English when appropriate to task and situation.

Common Core Math Standards

MP - Math Practices
  • MP.1 - Make sense of problems and persevere in solving them
  • MP.2 - Reason abstractly and quantitatively
  • MP.3 - Construct viable arguments and critique the reasoning of others
  • MP.5 - Use appropriate tools strategically
  • MP.6 - Attend to precision
  • MP.7 - Look for and make use of structure
  • MP.8 - Look for and express regularity in repeated reasoning
OA - Operations And Algebraic Thinking
  • 4.OA.1 - Interpret a multiplication equation as a comparison, e.g., interpret 35 = 5 × 7 as a statement that 35 is 5 times as many as 7 and 7 times as many as 5. Represent verbal statements of multiplicative comparisons as multiplication equations.
  • 4.OA.5 - Generate a number or shape pattern that follows a given rule. Identify apparent features of the pattern that were not explicit in the rule itself. For example, given the rule “Add 3” and the starting number 1, generate terms in the resulting sequence and

Next Generation Science Standards

ETS - Engineering in the Sciences
ETS1 - Engineering Design
  • 3-5-ETS1-1 - Define a simple design problem reflecting a need or a want that includes specified criteria for success and constraints on materials, time, or cost.