D1: Loops - Nested Loops
Students will learn how and why to use Nested Loops. They will use Blockly preset programs and Challenge Cards to practice their new skills.

Lesson
Overview
Description
Students will learn how and why to use Nested Loops. They will use Blockly preset programs and Challenge Cards to practice their new skills.
Objectives
understand the definition of a nested loop
distinguish between when a nested loop should be used instead of a simple or regular loop
create a program that uses a nested loop in order to solve a puzzle
use loops to revise code and complete coding challenges in an iterative process
Before the Lesson
Prior Experience
It is recommended that students complete:
Level A-C: Lessons 1-6
[Optional] Level A-C Challenge Cards: All
You can purchase our Learn to Code Challenge Card sets and Curriculum Guide here: https://store.makewonder.com/#/education
Preparation
Fully charge the tablets and robots.
Install the Wonder Workshop Blockly app on each tablet.
Review
Loops
Briefly review loops with the students by asking:
"What are loops?" (Sample response: "Loops are bits of code that repeat.")
"Why do we use loops in coding?" (Sample response: "Loops allow us to repeat code over and over, as many times as we need, in a very simple way.")
Code.org Connections (Optional)
Review Code.org's Course D, Lesson 4: https://curriculum.code.org/csf/coursed/4/. Then ask:
How do nested loops work? (Sample response: "You place one or more repeat loops inside another repeatloop.")
Direct Instruction
Introduction
Say, "Think of a bird's nest and what it looks like." Draw a picture of a bird's nest on the board or smartboard. "Now think of how a bird fits inside the nest." Add birds to the nest.
Have students choose partners. Ask, "What do you think a "nested loop" looks like using block coding?"
Have partners discuss and draw a prediction of what they think a nested loop looks like (on paper or a tablet screen).
Project your tablet screen and open the Blockly app.
Go to the Create New Project menu and select the Fight the Fire preset program. Then tap “create.”

Have students compare their nested loop prediction illustrations to the nested loop in the Fight the Fire preset program.
Then ask student pairs to write their own definition of a nested loop. (Sample Response: "Nested Loops are loops that are found inside another loop.")
Quick Check
What do nested loops look like? (Sample response: "A nested loop is one loop with one or more loops placed inside it.")
Guided Practice
Activity: Fighting the Fire

Say, "We just looked at a program that uses nested loops." Point to the nested loop that is used in this program.
Then say, "Why do we say that it's 'nested'?" (Sample response: “We say it’s nested because it is inside of another repeat block, just like birds are inside of a nest.”)
Say, "Look at the program and predict what will happen when we run it with Dot." (Sample response: "Dot will make a fire engine noise and then go through all the light patterns two times. Then the entire process will repeat 5 times.")
Run the program and see if the student predictions were correct.
Ask: "What would happen if we changed the number in either repeat block?"
"What would happen if we used a Repeat Forever block?"
"How could we nest an additional repeat block in the program?" (Sample response: "We could add a new repeat block inside the first repeat block. The new repeat block could repeat some sounds.")
"Where would we have to place the repeat block in order for it to be considered nested?" (Sample response: "The repeat block would have to be placed inside another repeat block.")
Independent Practice
Instructions
Have students work on the following activities in small groups (ideally 2-3 students per robot).
Encourage students to share tablet and robot time. Have them establish and rotate through roles such as:
Lead Programmer: Holds the tablet and manipulates the code.
Robot Wrangler: Retrieves and resets the robot after every program attempt.
Documentarian: Records group results, thoughts, and progress. Illustrates group designs and ideas.
When students work together while coding, they're able to help each other identify mistakes and develop creative solutions!
Fight the Fire - Extension
Have students use the Wonder Journal: Dot Planning and/or General Planning worksheet to to discuss how they want to add or alter the Fight the Fire preset program. They can:
Change the cues that are used.
Change the sounds and/or animations.
Add lights or sounds.
After they finish revising the program, have students:
Complete a Wonder Journal: Reflection worksheet.
Take a screenshot of their Blockly code.
Take a video of Dot while the code is running.
Challenge Cards (Optional)
You can purchase our Learn to Code Challenge Card sets and Curriculum Guide here: https://logicsacademy.com/store/
Have students complete the following Challenge Cards:
D 1.1: Cheer Up, Friends!
D 1.2: Step It Up!
D 1.3: Happy Dance Flash Mob
For each challenge, encourage students to:
Use the Wonder Journal: Dash Planning and/or General Planning worksheet to discuss how they can complete the challenge.
Review the Troubleshooting and Problem Solving & Debugging worksheets if they run into any problems with their code.
After they finish each challenge, have students:
Complete a Wonder Journal: Reflection worksheet.
Take a screenshot of their Blockly code.
Take a video of Dash while the code is running.
Update their Challenge Card Checklists.
Wrap Up
Student Presentations
Have student groups take turns sharing one of their programs with the class. Encourage them to:
Explain their design thinking (e.g., "We wanted to add another loop to the program because we thought it would make it more interesting.” "We used the Repeat block/s in order to make our code shorter.”).
Share any obstacles and difficulties they overcame during the activity (e.g., "At first, we didn't know how to make a custom eye pattern for Dot, but then we tapped the Eye Pattern block and tapped the lights around the circle.”).
Encourage students to ask each other how they accomplished different objectives and give each other feedback on their programs. Possible questions/feedback includes:
"How did you (create that Eye Pattern)?"
"I like how you (added lights and sounds to your program)."
"What if you (used a Repeat Forever block)?"
Follow-Up Questions/Discussion
Nested Loops are used when a larger process is broken down into smaller pieces. These processes in everyday life are similar to Nested Loops in code:
You perform a loop by going to school every day. As part of the school day, you have lunch and perform a loop to eat your food by taking a bite food, chewing, and then swallowing. That eating loop is nested inside the going to school loop.
Can you think of a time in your life when you use a process similar to Nested Loops?
Assessment
Use our Evaluation Rubric to review students' work and presentations.
[Optional] Share your students' work with the world using @logicsacademy and #dashanddot!
Educational Standards
CSTA
CSTA
1B-AP-10: Create programs that include sequences, events, loops, and conditionals.
1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.
1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features.
1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended
1B-AP-16: Take on varying roles, with teacher guidance, when collaborating with peers during the design, implementation, and review of program development.
1B-AP-17: Describe choices made during program development using code comments, presentations, and demonstrations.
2-AP-12: Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
ISTE
ISTE
4d: Exhibit a tolerance for ambiguity, perseverance and the capacity to work with open-ended problems.
5a: Formulate problem definitions suited for technology-assisted methods such as data analysis, abstract models and algorithmic thinking in exploring and finding solutions.
6b: Create original works or responsibly repurpose or remix digital resources into new creations.
7c: Contribute constructively to project teams, assuming various roles and responsibilities to work effectively toward a common goal.
NGSS
NGSS
3-5-ETS1-2: Generate and compare multiple solutions to a problem based on how well they meet the criteria and constraints of the design problem.
Common Core
Common Core
CCSS.ELA-LITERACY.W.2.8: Recall information from experiences or gather information from provided sources to answer a question.
CCSS.ELA-LITERACY.SL.3.1: Engage effectively in a range of collaborative discussions (one-on-one, in groups, and teacher-led) with diverse partners on grade 3 topics and texts, building on others' ideas and expressing their own clearly.
CCSS.ELA-LITERACY.SL.3.3: Ask and answer questions about information from a speaker, offering appropriate elaboration and detail.
CCSS.ELA-LITERACY.SL.3.4: Report on a topic or text, tell a story, or recount an experience with appropriate facts and relevant, descriptive details, speaking clearly at an understandable pace.
Alberta - Grade 3 - ICT
Grade 3
ICT
C5: Students will use technology to aid collaboration during inquiry.
C6: Students will use technology to investigate and/or solve problems.
F6: Students will demonstrate a basic understanding of the operating skills required in a variety of technologies.
Ontario - Grade 3 - Mathematics
Grade 3
Mathematics: Algebra (Coding)
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential, concurrent, and repeating events
Nova Scotia - Grade 3 - ICT
Grade 3
ICT
Outcome 5: Students will be expected to select and use, with teacher support, grade-appropriate digital tools to develop and represent learning for various purposes, both individually and collaboratively.
Outcome 9: Students will be expected to
use grade-appropriate ICT terminology
safely operate computers and digital devices
British Columbia - Grade 3 - ADST
Grade 3
ADST
• Use trial and error to make changes, solve problems, or incorporate new ideas from self or others
• Develop their skills and add new ones through play and collaborative work
• Explore the use of simple, available tools and technologies to extend their capabilities
