Cover Page

Code Jumper Curriculum: Lessons, Lesson 7 Loops and Sequences

American Printing House for the Blind

Code Jumper Curriculum: Lessons

Copyright © 2020 American Printing House for the Blind

All rights reserved. No part of this publication may be reproduced, stored in retrieval system, or transmitted in any form or by any means, except as expressly permitted under copyright law, without written permission of the publisher.

Published by American Printing House for the Blind

1839 Frankfort Avenue, Louisville, KY 40206

www.aph.org | [email protected]

Overview

Lesson Objectives

Students will:

  • Understand the computer programming concepts of loops and sequences
  • Be able to develop a program that includes loops and sequences

Expected Outcomes

Students will:

  • All students: Be able to identify loops and sequences in existing programs
  • Most students: Be able to recreate a program that requires a loop and a sequence
  • Some students: Be able to create an original program that uses loops and sequences

Lesson Plan Structure

  • Unplugged Activity
  • Guided Code Jumper Activity
  • Exploration
  • Standards and Check for Understanding

Key Vocabulary

  • Loop: A way to organize commands in a computer program so they repeat a sequence of instructions a required number of times. In the case of the Code Jumper Loop pod, the loop will continue to repeat the sequence a set number of times.
  • Repetition: Repeating a set of commands in a computer program using a loop.
  • Sequence: Where one action is followed by another action.

Resources

Unplugged Activity: Combining Repetition and Single Actions

Objective

Introduce the students to the idea of how loops and individual sequences can be combined to complete a task.

Overview

Students will work together to identify where both loops and individual sequences can be used to create an algorithm, or step- by-step process to complete a task.

(Teacher background information) In computer science, the use of loops is a very powerful tool to create algorithms. However, many times programs consist of a series of repetitive tasks that finish and then require a series of individual tasks to be performed without repetition. Software engineers and programmers know how to identify single tasks and repetitive actions and combine them into a complete algorithm.

Materials

  • Loops and Sequences Cards (see end of lesson)

Getting Started

  1. Explain to students that they will be working in small groups to identify loop commands, brainstorm the event or events that will have to take place prior to the repetitive activity, and what event or events will happen at the end of the activity.
  2. Place students in groups of three to five, depending on the size of the class.
  3. Instruct students to sit together in small groups in an area where they can work together.
  4. Provide each group with a Loops and Sequences Card that has a repetitive task or loop example on it.
  5. Review with the class that a loop is a way to organize commands in a computer program so they repeat a sequence of instructions a required number of times. A sequence is where one action is followed by another action.
  6. Explain that each group received a card with a loop/ repetitive task on it. The goal of the activity will be for their group to discuss the tasks on the card and come up with the event or events that have to happen before or after the loop to make the sequence complete. (Example: Before picking blueberries, they would need a bucket or container to keep the blueberries in. After picking blueberries, they would need to wash them in order to eat them.)
  7. Have each group of students share with the class their card with the loop on it and the task that had to take place before and after the loop in the sequence for it to be complete.
  8. Explain to students that people who make computer programs use a combination of both loops and single tasks in a sequence to complete a task.

Guided Activity: Combining Loops and Single Sequences

Objective

Students will:

  • Identify a series of commands that repeat and combine them into loops
  • Identify commands that occur only once in a sequence
  • Be introduced to combining loops and single sequences in a program
  • Practice reading the code

Materials

  • Code Jumper kit: Hub, Play and Loop pods
  • Loops and Sequence Melody Code Card with Loop Piano Sound Set in the MIDI Instruments Sound Category
  • Loops and Sequence Melody Code Card without Groups:
  • Loops and Sequence Melody Code Card with Groups

Instruction

  1. Divide students into groups of two to three. Each group will use one Code Jumper kit.
  2. Review the Loop pod and Loop function, reminding students that the shorter cord is for the main program and the longer cord is part of the loop.
  3. Review loops with students. A loop is a repetition of a series of commands within a sequence. Ask students: Why would we use loops? What are the benefits of using a loop?
  4. Either copy and distribute the Code Card below or include it as part of each student’s Computer Science Journal. Before students set up the physical program in Code Jumper, they will look at the written code to find loops.
  5. Looking at the code in groups helps students determine where loops can be placed.
  6. See printable Loops and Sequence Melody Card Cards at the end of the lesson.

Loops and Sequence Melody Code Card Without Groups:

THREAD 1 Piano

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY F5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

END THREAD

Loops and Sequence Melody Code Card with Groups:

THREAD 1 Piano

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

*

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

*

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

*

PLAY F5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

END THREAD

Melody Code Card with Loop:

THREAD 1 Piano

LOOP 3 times

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

END LOOP

PLAY F5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

END THREAD

  1. Ask students to connect one Play pod to the Hub and choose the Piano Sound Set in the MIDI Instruments Sound Category.

    A screenshot of the Code Jumper app showing a grayed-out program in Thread 1 and a pop-up dialog box where you can change the Sound Category and Sound Set.

    A photo of the Code Jumper Hub with one Play pod connected to the Hub at Port 1.

    [Figure Caption:] At the top is a screenshot of the Code Jumper app showing a grayed-out program in Thread 1 and a pop-up dialog box where you can change the Sound Category and Sound Set. In the dialog box, the Sound Category is MIDI Instruments and the Sound Set is Piano. Below this screenshot is a photo of the Code Jumper Hub with one Play pod connected to the Hub at Port 1.
  2. Ask students to find E5 in the Sound Set. Students will need to either look at the app visually, read the code by pressing the Read button in the App, or simultaneously press Play and Stop to determine if it is the correct note.
  3. Next, ask students to add a second Play pod to the first Play pod and find G5. It is important that students are tracing the code while it is being read aloud to determine which Pod is playing which sound.

    Acreenshot of the Code Jumper app showing a program in Thread 1.

    [Figure Caption:] This screenshot of the Code Jumper app shows a program in Thread 1. Below Thread 1 Piano, the commands read, PLAY E5 for 1 beat, PLAY G5 for 1 beat; the commands are followed by End Thread.
  4. Instruct students to play the two notes while tracing the code, noting that the names of the notes are not being said, but instead the actual note is played.
  5. Distribute the Code Card for the melody to each student. Instruct students to individually look through the code, identify any parts of the code that repeat, and circle them in their Computer Science Journals. (The first three lines are repeated three times.) Braille users can use wax sticks or stickers to indicate repeats. If looking at the code digitally, ask students to either put a space between the repeated sections or add a symbol such as the asterisk to indicate each grouping.
  6. Ask students to give identical lines a number to indicate how many times a sequence repeats. (There are three lines that repeat three times.)
  7. Discuss with students the difference between the first nine lines of code and the last four. Ask students: What is different? Can we put the last four lines in a loop? Why or why not? What do we do with those last four lines?

    A 13-command Code Jumper program in THREAD 1 Piano.

    [Figure Caption:] The text displayed in this figure reflects a 13-command Code Jumper program in THREAD 1 Piano. The first nine identical commands are circled in sets of three and labeled 1, 2, and 3. These repeated commands read, PLAY C5 for 1/2 beat, PLAY E5 for 1/2 beat, PLAY D5 for 1/2 beat. The last four commands, which are not circled or labeled, read, PLAY F5 for 1/2 beat, PLAY E5 for 1/2 beat, PLAY D5 for 1/2 beat, PLAY C5 for 1/2 beat; the commands are followed by END THREAD.
  8. Discussion: How we can make this program with the Pods that we have in one Code Jumper kit? If not, how can we make this program with what we have? (Answer: Use the Loop pod.)
  9. Explain: In this program, we have a loop, but after the loop finishes there are more sounds in the program. The loop is only part of the program, and it continues on to different sounds. We have 13 total sounds in our program: Three sounds played in a loop three times for nine sounds, plus four more single sounds played after the loop.
  10. Ask students to create the loop and sequence using Code Jumper. Remember, if you hear a burp that means there is an error. Check to make sure that your Loop pod is plugged in correctly.
  11. Remind students to listen to the code to determine the correct note. Then match it to the Code Card to debug the program. Instruct students to run the program for the teacher.

Closure

  • Ask students to explain how repetition and sequences can be used together and to give an example of how they used them in this lesson.
  • Ask students: Where does the loop start and end? In which direction does the loop run?

Exploration

Objective

Students will listen to the song Row Your Boat and recreate it using loops and sequences.

Materials

  • Loops and Sequence Exploration Row Your Boat Code Card

Instruction

There are multiple Sound Sets that work well for loops and sequences. Or, you can create a custom Sound Set to use that is specific to your classroom.

THREAD 1 Row Your Boat

LOOP 3 times

PLAY Row for 1 times speed

END LOOP

PLAY Your boat for 1 times speed

PLAY Gently down the stream for 1 times speed

PLAY Merrily 1 for 1 times speed

PLAY Merrily 2 for 1 times speed

PLAY Merrily 3 for 1 times speed

PLAY Merrily 4 for 1 times speed

PLAY Life is but a dream for 1 times speed

END THREAD

  1. Prior to the lesson, create the program Row Your Boat using the Code Card above.
  2. Instruct students to listen to the program or have them sing the song out loud.

    Direct students to load the Sound Set Sample Sounds: Row Your Boat into one of the Code Jumper threads.

    A screenshot of the Code Jumper app with a program in Thread 1.

    A photo of a Code Jumper program containing eight Play pods and a Loop pod in Port 1.

    [Figure Caption:] At the top is a screenshot of the Code Jumper app with a program in Thread 1. Under THREAD 1 Row Your Boat, the commands read, LOOP 3 times, PLAY Row for 1 times speed, END LOOP, PLAY Your boat for 1 times speed, PLAY Gently down the stream for 1 times speed, PLAY Merrily 1 for 1 times speed; PLAY Merrily 2 for 1 times speed, PLAY Merrily 3 for 1 times speed, PLAY Merrily 4 for 1 times speed, PLAY Life is but a dream for 1 times speed; the commands are followed by END THREAD. Below this screenshot is a photo of a Code Jumper program containing eight Play pods and a Loop pod in Port 1. One end of the Loop pod is connected directly to the Hub at Port 1 and consists of one Play pod. The remaining seven Play pods are connected, one after the other, to the other end of the Loop pod.
  3. Have students write down what they think the code will be in their Computer Science Journals.
  4. Instruct students to recreate the program according to the code they wrote down. Have students debug their programs, if necessary.

Closure

  • Ask students to compare the code they wrote down in their Computer Science Journals with the code shown in the Code Jumper app.
  • As an extension, ask students to create their own programs using a loop and a sequence:
    • First, instruct them to write down or touch-type the code.
    • Then, have them use the code they just wrote to create the program in the Code Jumper kit.

Standards and Check for Understanding

CSTA K-12 Computer Science Standards*

  • 1B-AP-08: Compare and refine multiple algorithms for the same task and determine which is the most appropriate.
  • 1B-AP-10: Create programs that include sequences, events, loops, and conditionals.

National Curriculum of England**

Key Stage 1:

  • Understand what algorithms are; how they are implemented as programs on digital devices; and that programs execute by following precise and unambiguous instructions
  • Create and debug simple programs
  • Use logical reasoning to predict the behavior of simple programs
  • Use technology purposefully to create, organize, store, manipulate and retrieve digital content
  • Recognize common uses of information technology beyond school
  • Use technology safely and respectfully, keeping personal information private; identify where to go for help and support when they have concerns about content or contact on the internet or other online technologies

Key Stage 2:

  • Design, write and debug programs that accomplish specific goals, including controlling or simulating physical systems; solve problems by decomposing them into smaller parts
  • Use sequence, selection, and repetition in programs; work with variables and various forms of input and output
  • Use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs
  • Use search technologies effectively, appreciate how results are selected and ranked, and be discerning in evaluating digital content
  • Use technology safely, respectfully and responsibly; recognize acceptable/unacceptable behavior; identify a range of ways to report concerns about content and contact

Closing Activities and Check for Understanding

  • Ask students to explain how repetition and sequences can be used together
  • Ask students to explain how they used repetition and sequences in this lesson
Check for understanding Completed
Student can identify tasks that involve repetition and tasks that occur once in a sequence. Yes / No
Student can identify and break down programs into sets of sequences that repeat as a loop and sequences that occur only once. Yes / No
Student can identify steps within a task that involve both repetition and single occurrences and recreate them using loops and single sequences within Code Jumper. Yes / No

Code Cards

Sample Program Setup

  • Sample program set up and run by the teacher: Melody with Loop and Sequence
    • Sound Set: MIDI Instruments : Piano at Thread 1

THREAD 1 Piano

LOOP 3 times

PLAY C5 for 1/2 a beat

PLAY E5 for 1/2 a beat

PLAY D5 for 1/2 a beat

END LOOP

PLAY F5 for 1/2 a beat

PLAY E5 for 1/2 a beat

PLAY D5 for 1/2 a beat

PLAY C5 for 1/2 a beat

END THREAD

  • Sample program set up and run by the teacher: Row Your Boat
    • Sound Set: Sample Sounds : Row Your Boat at Thread 2

THREAD 2 Row Your Boat

LOOP 3 times

PLAY Row for 1 times speed

END LOOP

PLAY Your boat for 1 times speed

PLAY Gently down the stream for 1 times speed

PLAY Merrily 1 for 1 times speed

PLAY Merrily 2 for 1 times speed

PLAY Merrily 3 for 1 times speed

PLAY Merrily 4 for 1 times speed

PLAY Life is but a dream for 1 times speed

END THREAD

Guided Activity Code Cards

Loops and Sequence Melody Code Card Without Groups:

THREAD 1 Piano

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY F5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

END THREAD

Loops and Sequence Melody Code Card with Groups:

THREAD 1 Piano

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

*

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

*

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

*

PLAY F5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

END THREAD

Loops and Sequence Melody Code Card with Loop:

THREAD 1 Piano

LOOP 3 times

PLAY C5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

END LOOP

PLAY F5 for ½ a beat

PLAY E5 for ½ a beat

PLAY D5 for ½ a beat

PLAY C5 for ½ a beat

END THREAD

Exploration Code Card

Loops and Sequence Exploration Row Your Boat Code Card

THREAD 1 Row Your Boat

LOOP 3 times

PLAY Row for 1 times speed

END LOOP

PLAY Your boat for 1 times speed

PLAY Gently down the stream for 1 times speed

PLAY Merrily 1 for 1 times speed

PLAY Merrily 2 for 1 times speed

PLAY Merrily 3 for 1 times speed

PLAY Merrily 4 for 1 times speed

PLAY Life is but a dream for 1 times speed

END THREAD

Loops and Sequences Card #1:

Jumping rope

Loops and Sequences Card #2:

Handing out papers

Loops and Sequences Card #3:

Setting a table

Loops and Sequences Card #4:

Sharpening pencils

Loops and Sequences Card #5:

Brushing your teeth

Loops and Sequences Card #6:

Eating popcorn

Loops and Sequences Card #7:

Picking blueberries

Loops and Sequences Card #8:

Shooting a basketball

Code Jumper

For more resources, visit codejumper.com

Copyright © 2020

American Printing House

1839 Frankfort Avenue

Louisville, Kentucky 40206

502-895-2405 • 800-223-1839

www.aph.org[email protected]