Lesson 18: Conditionals & Loops in Maze

Conditional | Loop | Maze | Angry Bird | Zombie

Overview

In this lesson, students will be pairing together two key concepts: loops and conditionals. This set of puzzles bridges the gaps in understanding that occur when working on puzzles that use multiple kinds of blocks. By bringing two ideas together, students will create more complex code that shows both impressive creativity and critical thinking!

Purpose

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

Agenda

Warm Up (10 min)

Main Activity (30 min)

Wrap Up (15 min)

Extended Learning

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

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Teacher

For the Students

Vocabulary

  • Condition - A statement that a program checks to see if it is true or false. If true, an action is taken. Otherwise, the action is ignored.
  • Conditionals - Statements that only run under certain conditions.
  • Loop - The action of doing something over and over again.
  • Repeat - Do something again
  • While Loop - A loop that continues to repeat while a condition is true.

Support

Report a Bug

Teaching Guide

Warm Up (10 min)

Introduction

Students will be bringing together the new while loops and new if / else statements, so this introduction will go over what these blocks do in a general sense.

While Loops

Ask the class if they remember what "while" means in coding. Go over the definition of a while loop.

  • While Loop: A loop that continues to repeat while a condition is true.

In addition to while loops, students will practice with until loops in this set of puzzles. Explain to the students that while loops continue to repeat code while a condition is true, whereas until loops continue until a condition is true.

For example, with a while loop, the zombie will continue to walk down a path while there is a path ahead. With an until loop, the zombie will continue to walk forward until it reaches the flower at the end of the path. This will be shown in more detail inside the puzzles.

If / Else Statements

Ask the class if they remember what "if" and "else" mean in coding. Go over the definition of a conditional.

  • Conditional: Statements that only run under certain conditions or situations.

Students will be using conditionals to test if there are paths to the left or right. Explain that conditionals are extremely flexible and can be used in a way that your program can adapt to almost any situation.

All Together Now

Ask the class to explain why while loops are conditionals. How are they different from if / else statements? Open up a discussion on when to use while loops and when to use if / else statements.

Main Activity (30 min)

CSF Express Course - Website

Bringing together concepts is not easy, but this set of lessons is meant to bridge if / else statements and while loops together for students to see the endless possibilities of coding when using the pair. If students struggle at all with understanding the similarities or differences between if / else statements, while loops, or until loops, have them go back and practice on previous puzzles that only uses one of the three.

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?
  • What do you like using the most: if / else statements, until loops, or while loops? Why?

Extended Learning

Until Simon Says

Go out to a large playing field and have the students stand in a line facing you. Make sure every student can see you. Declare a couple of "until loops" such as:

  • Until my right hand is raised up, you can walk toward me
  • Until I say "eggplant", you can walk backwards in my direction
  • Until I turn my head is to the right, you have to walk like a crab

The first student to get to you wins. If there's time, let other students be "Simon" at the front of the class.

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards

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