Lesson plan

Python 101 with MakeCode - Lesson 7

Program the Agent using while loops and sequences to respond to simulated disasters by building barriers, firebreaks, and home foundations.

Python 101 with MakeCode - Lesson 7
Ages
Ages 11+
Duration
1 hour
Essential question

How can while loops and ordered sequences help an autonomous Agent navigate and construct in hazardous, changing environments?

Overview

In this lesson, students explore automated emergency relief by programming the Agent to perform construction tasks in areas too hazardous for human workers. Learners discover how while loops and sequences allow autonomous assistants to navigate dynamic environments, repeating vital construction actions until safety criteria or spatial boundaries are reached.

Using simulated disaster zones in Minecraft, students code the Agent to follow pre-laid Redstone dust guidelines. By directing the Agent to assemble flood barriers, build concrete firebreaks across uneven terrain, and lay reconstructed home foundations, learners see how conditional code solves real-world logistics challenges.

Learning objectives

By the end of this lesson students will be able to:

  • Utilize while loops to repeat code blocks based on active conditions.
  • Recognize the importance of sequence order in program execution.
  • Apply conditional loops to follow Redstone dust guides over varied terrain.
  • Distinguish when to choose a while loop over a for loop for autonomous navigation.

Blocks and items used in this lesson

Key vocabulary

While Loop
A programming structure that continues to repeat an action as long as its specified condition remains true.
Sequence
The exact order in which a computer executes a series of commands.
Condition
A logical test evaluated by code to decide whether to execute an action.
Firebreak
An obstacle or cleared strip of land designed to halt the advance of an active fire.

Before class

Lesson sequence

Suggested timing: about 60 minutes in total.

  1. Concept Introduction10 min

    Introduce the emergency response scenario using the classroom presentation. Explain how while loops operate based on conditions and demonstrate why precise sequence order matters when the Agent executes multi-step commands.

  2. Activity 1: Water Barrier15 min

    Direct students to help emergency personnel by programming the Agent to lay down a protective water barrier along marked Redstone guidelines to halt floodwaters.

  3. Activity 2: Firebreak20 min

    Task students with building a one-block-high concrete firebreak across uneven terrain. Learners must implement two while loops—one following the Redstone dust path and another checking ground elevation—combining a flat placement sequence with an elevation-climbing sequence.

  4. Activity 3: Home Reconstruction10 min

    Have students code the Agent to rebuild house foundations following a hurricane by reading and tracing the foundation layout marked out in Redstone dust.

  5. Review and Formative Check5 min

    Gather the class to review key concepts using the formative assessment questions, focusing on loop conditions, sequence definitions, and when to favor while loops over for loops.

Assessment: success criteria

  • The student creates a functioning while loop that repeats commands only while its condition remains true.
  • The Agent successfully navigates uneven ground by triggering the correct sequence when elevation changes.
  • The student can explain that while loops are chosen over for loops when the total number of movement steps is unknown.

Differentiation

Support

Walk through the two separate firebreak movement sequences on the board before students attempt to nest their elevation-checking while loop.

Stretch

Ask advanced students to refine their firebreak code so it minimizes unnecessary checks while handling varying step heights.

Knowledge check

5 questions to check understanding after the lesson. Tap an answer to see if it is right; the score appears at the end.

  1. 1When does a while loop repeat its code?

  2. 2What is a sequence in computer science?

  3. 3What happens if the condition in a while loop is false?

  4. 4When would you choose a while loop instead of a for loop to move the Agent forward?

  5. 5In Activity 2, why does the Agent need two different sequences to build the firebreak?

Resources

Part of the Python 101 curriculum

This is lesson 7 of 10 in Python 101.

  1. Python 101 with MakeCode - Lesson 1
  2. Python 101 with MakeCode - Lesson 2
  3. Python 101 with MakeCode- Lesson 3
  4. Python 101 with MakeCode - Lesson 4
  5. Python 101 with MakeCode - Lesson 5
  6. Python 101 with MakeCode - Lesson 6
  7. Python 101 with MakeCode - Lesson 7
  8. Python 101 with MakeCode - Lesson 8
  9. Python 101 with MakeCode - Lesson 9
  10. Python 101 with MakeCode - Lesson 10

Frequently Asked Questions

How does the Agent know where to build the emergency structures?

Emergency workers have laid down visual path guidelines using Redstone dust, which students program the Agent to follow during each activity.

What specific actions make up the two sequences in the firebreak activity?

The first sequence directs the Agent to place a block to its left and move forward. The second sequence directs the Agent to place a block to its left, move up, place another block, and then step forward to accommodate elevation shifts.

Adapted from Python 101 with MakeCode - Lesson 7 by Minecraft Education on Minecraft Education, last updated Jun 14, 2023. This classroom version, the timings and the quiz were written by 9Minecraft Education.

You May Also Like

9Minecraft Education is an independent teaching resource and is not affiliated with Mojang or Microsoft. Lesson plans here are our own classroom-ready adaptations; each one links to the original resource and credits its author. © 2026 9minecraft.net