Lesson plan

Conditional Loops

Program the Agent using conditional while loops in MakeCode to clear paths, build bridges, navigate spirals, and cultivate a 40-block farm row.

Conditional Loops
Ages
Ages 8-18
Essential question

How can conditional loops allow the Agent to interact with and respond to its environment?

Overview

Conditional loops allow computer programs to repeat instructions based on live environmental data rather than a fixed count. By utilizing while conditions, coders instruct programs to evaluate states as true or false continuously, making automated tasks adaptable to their surroundings.

In this lesson, learners use Minecraft Education and the MakeCode editor to command the Agent. Students can choose between Blocks, JavaScript, or Python across three progressive challenges before applying conditional loops to an automated life science farming task.

Learning objectives

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

  • Explain the role of conditions and the while command in coding loops.
  • Program the Agent to repeat actions based on environmental conditions.
  • Apply conditional loops to automate crop cultivation along a designated plot.

Blocks and items used in this lesson

Key vocabulary

Condition
The state of an object or environment that evaluates to true or false.
Conditional Loop
A programming structure that repeats actions as long as a specified condition is true.
While
A programming statement used to keep a loop executing until a condition changes.

Before class

Lesson sequence

Suggested timing: about 65 minutes in total.

  1. Warm-up and Discussion10 min

    Introduce conditional decision-making through real-life scenarios, such as turning a door handle only when a door is closed or wiping surfaces only where a spill is visible.

    Discuss how computers make similar choices by checking whether a statement is true or false before repeating an action.

  2. Tiered Coding Tutorials30 min

    Students open MakeCode, choose their preferred language (Blocks, JavaScript, or Python), and work through one or all of the tutorials based on difficulty:

    • Tutorial 1 - Novice (5 min): Code the Agent to clear a blocked passage.
    • Tutorial 2 - Intermediate (10 min): Program the Agent to construct a bridge across an obstacle.
    • Tutorial 3 - Expert (15 min): Guide the Agent through a winding spiral layout.
  3. Applied Science Challenge20 min

    Students apply conditional loops to a life science farming scenario. Working along a plot measuring 1 block wide by 40 blocks long, learners program the Agent to automatically till the land, sow seeds, and apply bone meal to support crop growth.

  4. Review and Assessment5 min

    Regroup to evaluate student understanding of conditional logic. Review the role of the while command and prompt learners to explain how their code responded to environmental conditions.

Assessment: success criteria

  • The student defines a condition as a state that evaluates to true or false.
  • The student explains how a while loop continues repeating actions until a condition changes.
  • The student programs the Agent to navigate, clear, or build in at least one tutorial challenge.
  • The student creates a functional conditional loop that tills, plants, and fertilizes a 1x40 block farm row.

Differentiation

Support

Learners needing additional guidance can use the visual Blocks editor and focus on completing the five-minute Novice passage-clearing tutorial.

Stretch

Students seeking an extra challenge can complete all three tutorial levels in JavaScript or Python before scripting the 40-block farming task.

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. 1What is a condition in computer programming?

  2. 2How does a conditional loop determine when to run?

  3. 3Which keyword is highlighted in the lesson for constructing conditional loops?

  4. 4What three items does the Agent use during the life science farming activity?

  5. 5What are the dimensions of the farming plot in the application task?

Resources

Part of the Coding Tutorials curriculum

This is lesson 2 of 9 in Coding Tutorials.

  1. Unit 2: Events
  2. Conditional Loops
  3. Conditionals
  4. Events
  5. Events in Programming
  6. For Loops & Nested Loops
  7. Functions
  8. Sequencing
  9. Variables

Frequently Asked Questions

Which programming languages are supported in these activities?

Students can write their programs using visual Blocks, JavaScript, or Python within the MakeCode editor.

Are students required to finish every tutorial?

No, students have the option to pick a single tutorial matching their skill level or attempt all three tutorials before completing the farming challenge.

How long does the entire lesson take?

Completing all three tutorials along with the applied agricultural activity takes approximately one hour.

Adapted from Conditional Loops by Minecraft Education on Minecraft Education, last updated Feb 4, 2025. 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