< Course C (2021)

Lesson 8: Loops with Rey and BB-8

50 minutes

Overview

This skill-building lesson has students using loops to help BB-8 efficiently traverse a maze.

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.

CSTA K-12 Computer Science Standards (2017)
    • 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.

Agenda

Objectives

Students will be able to:
  • 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.
  • Identify the benefits of using a loop structure instead of manual repetition.

Preparation

  • Play through the puzzles to determine if there will be any problem areas for your class.
  • Make sure every student has a reflection 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.

Teaching Guide

Warm Up (5 minutes)

Introduction

Review with students the "My Loopy Robotic Friends" activity:

  • What are loops?
  • Why do we use them?

Quickly show the students a program (with repeated steps) for the rest of the class to do. Ask the rest of the class to find the loops within the program and point them out.

If you're comfortable, give an introduction to BB-8 from Star Wars. Many children may be familiar with the lovable robot, but an introduction will surely build excitement.

Bridging Activity - Choose One (10 minutes)

This activity will help bring the unplugged concepts from "My Loopy Robotic Friends" into the online world that the students are moving into. Choose one of the following to do with your class:

Unplugged Activity Using Paper Blocks

Revisit "My Loopy Robotic Friends". This time, work with the class to "code" it out using *manipulatives instead of writing the instructions on paper. Make sure the students know that the blocks need to go from top to bottom and they all need to touch!

-Or-

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 10 for its staircase pattern. Ask the students to write a program to solve the puzzle on paper. Have the students circle repeated chunks and label with the number of repeats, the same way they did in "My Loopy Robotic Friends."

Main Activity (30 minutes)

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 minutes)

Reflection

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!
Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.