# Lesson 14: Until Loops in Maze

## Overview

In this lesson, students will learn about `until` loops. Students will build programs that have the main character repeat actions `until` they reach their desired stopping point.

## Purpose

This set of puzzles will work to solidify and build on the knowledge of loops by adding the `until` conditional. By pairing these concepts together, students will be able to explore the potential for creating complex and innovative programs.

## Objectives

### Students will be able to:

• Build programs with the understanding of multiple strategies to implement conditionals.
• Translate spoken language conditional statements and loops into a program.

## Preparation

• Play through the puzzles to find any potential problem areas for your class.
• Make sure every student has a journal.

## Vocabulary

• Condition - Something a program checks to see if it is true before allowing an action.
• Conditionals - Statements that only run under certain conditions.
• Loop - The action of doing something over and over again.
• Repeat - To do something again.
• Until - A command that tells you to do something only up to the point that something becomes true.

# Teaching Guide

## Warm Up (10 min)

### Introduction

In this lesson, students will be creating loops that only run `until` a condition is true. Help the students understand how this works by leading them in group activities and having them do an action `until` some condition is true. For example: Have students touch their nose `until` you tell them to stop.

### Preview of Online Puzzles

Pull up a puzzle from today's Code Studio puzzles. We recommend Puzzle 4.

• Ask the class what the bird should repeat to get to the pig.
• The bird should repeat `move forward`, `turn right`, `move forward`, and then `turn left`.
• Ask the class what they can use to repeat this code.
• The bird should repeat this pattern until it reaches the pig.

Fill in the rest of the code using the `repeat until` loop and press `Run`. Discuss with the class why this worked.

## Main Activity (30 min)

### Online Puzzles

Bringing together concepts is not easy, but this set of lessons is meant to help students see the endless possibilities of coding when using conditions. If students struggle at all with understanding the similarities or differences between `while` loops and `until` loops, have them try to think of how they would use similar statements in their real lives.

## Wrap Up (15 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 do you feel about today's lesson?
• What's the difference between an `until` loop and a `while` loop?
• Practice
• 1
• (click tabs to see student view)
View on Code Studio

### Student Instructions

• Repeat Until Statements
• 2
• (click tabs to see student view)
View on Code Studio

### Student Instructions

• Prediction
• 3
• (click tabs to see student view)
View on Code Studio

### Student Instructions

Take a close look at the code below. What do you think will happen when you click "Run"?

The bird will not move at all.

The bird will make it to the pig.

The bird will move forward and run into the TNT.

I don't know.

View on Code Studio

### Student Instructions

View on Code Studio

### Student Instructions

"Dear person. Me zombie. Me hungry. Must... get... to sunflower..."

Can you get the zombie to the sunflower using only the blocks that are available?

View on Code Studio

### Student Instructions

Use the `if` block to help the zombie decide when to turn, then get the zombie to the sunflower.

View on Code Studio

### Student Instructions

Help the zombie get to the sunflower.

View on Code Studio

### Student Instructions

Help the zombie get to the sunflower.

• Challenge
• 9
• (click tabs to see student view)
View on Code Studio

### Student Instructions

Challenge: Avoid the chompers and help the zombie get to the sunflower.

• Practice
• 10
• (click tabs to see student view)
View on Code Studio

### Student Instructions

Help the zombie get to the sunflower.

• Prediction
• 11
• (click tabs to see student view)
View on Code Studio

### Student Instructions

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

The zombie will pass the correct path and end up going back and forth forever.

The zombie will make it to the sunflower.

The zombie will turn right on the first path and go around in circles forever.

I don't know.

## Standards Alignment

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 1B-AP-11 - Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process.