Lesson 6: Loops with Rey and BB-8

Overview

Building on the concept of repeating instructions from "Getting Loopy," this stage will have students using loops to help BB-8 traverse a maze more efficiently than before.

Purpose

In this lesson, students will be learning more about loops and how to implement them in Blockly code. Using loops is an important skill in programming because manually repeating commands is tedious and inefficient. With the Code.org puzzles, students will learn to add instructions to existing loops, gather repeated code into loops, and recognize patterns that need to be looped. It should be noted that students will face puzzles with many different solutions. This will open up discussions on the various ways to solve puzzles with advantages and disadvantages to each approach.

Agenda

Bridging Activity - Loops (10 min)

Main Activity (30 min)

Wrap Up (5 - 10 min)

Extended Learning

View on Code Studio

Objectives

Students will be able to:

  • Identify the benefits of using a loop structure instead of manual repetition.
  • Break down a long sequence of instructions into the largest repeatable sequence.
  • Employ a combination of sequential and looped commands to reach the end of a maze.

Preparation

  • Play through the lesson to determine if there will be any problem areas for your class.
  • Make sure every student has a journal.

Links

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

For the Students

Vocabulary

  • Loop - The action of doing something over and over again.
  • Repeat - To do something again.

Support

Report a Bug

Teaching Guide

Bridging Activity - Loops (10 min)

Content Corner

Teaching this course as a class?

Our grade-aligned CS Fundamentals courses use unplugged lessons to build community and introduce tricky computer science concepts, including loops. Check out the lesson My Loopy Robotic Friends from Course C!

Previewing Online Puzzles as a Class

Pull up the online puzzles and choose a puzzle to do in front of the class. We recommend puzzle 8 for its staircase pattern. Ask the students to write a program to solve the puzzle on paper.

Main Activity (30 min)

Online Puzzes

As students work through the puzzles, see if they can figure out how many blocks they use with a loop vs. not using a loop. Pair Programming - Student Video works really well with this set of puzzles because there are a few ways to fill the loops. Push for friendly discussion between pairs in instances of disagreement on how to solve the puzzle. Have the students ask each other questions like:

  • How did you come up with that solution?
  • What are some benefits of solving the puzzle that way?

We also recommend having paper on hand for students to write out their code and find any repetition to use in loops.

Wrap Up (5 - 10 min)

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 build a review sheet for them to look to in the future.

Journal Prompts:

  • What was today’s lesson about?
  • How did you feel during today’s lesson?
  • How did loops make your program easier to write?
  • Think of something that repeats over and over again. What might the program for that look like?

Extended Learning

Use these activities to enhance student learning. They can be used as outside of class activities or other enrichment.

So Moving

  • Give the students pictures of actions or dance moves that they can do.
  • Have students arrange moves and add loops to choreograph their own dance.
  • Share the dances with the rest of the class.

Connect It Back

  • Find some YouTube videos of popular dances that repeat themselves.
  • Can your class find the loops?
  • Try the same thing with songs!
View on Code Studio

Student Instructions

"Hi, I'm an artist. You can write code to make me draw almost anything."

Play with the blocks in the toolbox to see what they do!

View on Code Studio

Student Instructions

"Let's make a cage for my pet monster!"

Drag blocks onto the screen to have the artist draw over the grey lines in the picture.
(Each line is 100 pixels long)

View on Code Studio

Student Instructions

"This spaceship needs a window!"

Each side of the inner square is 100 pixels and all of the angles are 90 degrees.

View on Code Studio

Student Instructions

"Oh no! Starla's pet alien just flew away! Let's help the spacewoman!"

Finish Starla's rocket so she can chase her pet.
(Each side of the triangle is 100 pixels long and has 120 degree outer angles.)

View on Code Studio

Student Instructions

"Maybe we should make a tag for each of our pets in case they get lost!"

Finish this tag by drawing a rectangle around the outside.
(The long sides are 200 pixels each and the short sides are each 100 pixels)

View on Code Studio

Student Instructions

"Now a tag for Belle!"

Draw this square with 200 pixel sides.

View on Code Studio

Student Instructions

Challenge: This tag is a special one!

Can you figure out how to draw the outline?
(The long side is 150 pixels and each of the short sides are 75 pixels.)

View on Code Studio

Student Instructions

One more tag. This is a triangle for Pi.
(Each side is 150 pixels)

View on Code Studio

Student Instructions

Look carefully at the code below. What will happen when you click "Run"?

The artist will draw a triangle with three equal sides.

The artist will draw a single line.

The artist will draw a square.

I don't know.

View on Code Studio

Student Instructions

Draw rooms for each of the animals. There are many different ways to solve this puzzle, so have some fun! Each square has a side length of 100 pixels.

View on Code Studio

Student Instructions

"Help me paint the yellow lines on this road!"

The three line segments have lengths of 150, 100, and 200 pixels!

Standards Alignment

View full course alignment

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.

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
  • 2.L.6 - Use words and phrases acquired through conversations, reading and being read to, and responding to texts, including using adjectives and adverbs to describe (e.g., When other kids are happy that makes me happy).
SL - Speaking & Listening
  • 2.SL.1 - Participate in collaborative conversations with diverse partners about grade 2 topics and texts with peers and adults in small and larger groups.

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.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
  • 2.OA.1 - Use addition and subtraction within 100 to solve one- and two-step word problems involving situations of adding to, taking from, putting together, taking apart, and comparing, with unknowns in all positions, e.g., by using drawings and equations with a sy

Next Generation Science Standards

ETS - Engineering in the Sciences
ETS1 - Engineering Design
  • K-2-ETS1-1 - Ask questions, make observations, and gather information about a situation people want to change to define a simple problem that can be solved through the development of a new or improved object or tool.
  • K-2-ETS1-2 - Develop a simple sketch, drawing, or physical model to illustrate how the shape of an object helps it function as needed to solve a given problem.
  • K-2-ETS1-3 - Analyze data from tests of two objects designed to solve the same problem to compare the strengths and weaknesses of how each performs.