Lesson 7: Loops with Scrat

Overview

Building on the concept of repeating instructions from "My Loopy Robotic Friends," this stage will have students using loops to get to the acorn more efficiently on Code.org.

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 these Code.org puzzles, students will learn to add instructions to existing loops, gather repeated code into loops, and recognize patterns that need to be repeated.

Agenda

Online Foundation: Preview Loops in Ice Age

Main Activity (30 min)

Wrap Up (5 - 10 min)

Extended Learning

View on Code Studio

Objectives

Students will be able to:

  • Construct a program using structures that repeat areas of code
  • Improve existing code by finding areas of repetition and moving them into looping structures

Preparation

  • (Optional) Pick a couple of puzzles to do as a group with your class.
  • Make sure each 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

Online Foundation: Preview Loops in Ice Age

To finish the connection, preview an online puzzle (or two) as a class.

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 Happy Loops from Course A and Getting Loopy from Course B!

Model: Reveal an entire online puzzle from the progression to come. Work with your class to drag code into the workspace in such a way that Scrat (eventually) gets to the acorn. Make sure to highlight the use of repeat blocks.

Transition: Students should now be ready to transition to computers to complete online puzzles on their own.

Main Activity (30 min)

As students work through the puzzles, see if they can figure out how many blocks they use with a loop vs. without a loop.

Online Puzzles

Teacher Tip:

Show the students the right way to help classmates by:

  • Don’t sit in the classmate’s chair
  • Don’t use the classmate’s keyboard
  • Don’t touch the classmate’s mouse
  • Make sure the classmate can describe the solution to you out loud before you walk away

Circulate: Teachers play a vital role in computer science education and supporting a collaborative and vibrant classroom environment. During online activities, the role of the teacher is primarily one of encouragement and support. Online lessons are meant to be student-centered, so teachers should avoid stepping in when students get stuck. Some ideas on how to do this are:

  • Utilize Pair Programming - Student Video whenever possible
  • Encourage students with questions/challenges to start by asking their partner
  • Unanswered questions can be escalated to a nearby group, who might already know the solution
  • Remind students to use the debugging process before you approach
  • Have students describe the problem that they’re seeing. What is it supposed to do? What does it do? What does that tell you?
  • Remind frustrated students that frustration is a step on the path to learning, and that persistence will pay off.
  • If a student is still stuck after all of this, ask leading questions to get the student to spot an error on their own.

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?
  • Draw one of the Feeling Faces - Emotion Images that shows how you felt about today's lesson in the corner of your journal page.
  • Draw Scrat and an acorn.
  • Draw yourself using a loop to do an everyday activity, like brushing your teeth.

Extended Learning

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

This game is called "Play Lab".

See if you can figure out what each block does.

View on Code Studio

Student Instructions

View on Code Studio

Student Instructions

Use an event to make Daisy the Dragon switch to a random mood when you click on her.

View on Code Studio

Student Instructions

Knight time! Get the dragon to finish this level.

Add an event so that the knight moves toward the dragon when the left arrow is clicked.

View on Code Studio

Student Instructions

Now add an event so that the knight runs away from the dragon when you press the right arrow.

Move the knight to the right to pass this level.

View on Code Studio

Student Instructions

Help your knight get all of the flags!

To do this, you'll need to add events to help the knight move up, down, left, and right.

View on Code Studio

Student Instructions

Make this game fun by adding more things!

1) Set the knight to vanish when he runs into the dragon.
2) Play a sound when they collide to make it feel more real.


Visit all of the goals, then run into the dragon to pass the level.

View on Code Studio

Student Instructions

View on Code Studio

Student Instructions

It's time for the Great Animal Race! Make the animals move down when you press .

Who will run the fastest?

View on Code Studio

Student Instructions

Let's make the animals disappear when you click on them. Try playing with the dog now, then help the other animals join in the fun. You can also add sounds and score points to create a game of Animal Tag!

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
  • 1.L.6 - Use words and phrases acquired through conversations, reading and being read to, and responding to texts, including using frequently occurring conjunctions to signal simple relationships (e.g., because).
SL - Speaking & Listening
  • 1.SL.1 - Participate in collaborative conversations with diverse partners about grade 1 topics and texts with peers and adults in small and larger groups.
  • 1.SL.1.a - Follow agreed-upon rules for discussions (e.g., listening to others with care, speaking one at a time about the topics and texts under discussion).
  • 1.SL.1.b - Build on others’ talk in conversations by responding to the comments of others through multiple exchanges.
  • 1.SL.1.c - Ask questions to clear up any confusion about the topics and texts under discussion.

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.4 - Model with mathematics
  • 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
  • 1.OA.1 - Use addition and subtraction within 20 to solve word problems involving situations of adding to, taking from, putting together, taking apart, and comparing, with unknowns in all positions, e.g., by using objects, drawings, and equations with a symbol for

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.