Lesson plan

Conditionals

Learn coding conditionals in MakeCode with three Agent tutorials and apply cause-and-effect rules to match planted crops with animal spawns.

Conditionals
Ages
Ages 8-18
Essential question

How do conditional statements and loops allow programs to make decisions based on specific conditions?

Overview

Conditionals allow programmers to establish cause-and-effect logic within software, directing a computer to take specific paths depending on whether conditions evaluate to true or false. In this lesson, students explore foundational logic through real-world rules and computer science principles, discovering how conditional statements and loops control repeated behaviors.

Using the MakeCode editor within Minecraft Education, learners program their Agent to navigate mazes, harvest timber, or construct pyramids across Novice, Intermediate, and Expert challenges using Blocks, JavaScript, or Python. Finally, an interdisciplinary Language Arts task asks students to read signs at animal enclosures and write conditional scripts that trigger animal spawns when designated crops are planted.

Learning objectives

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

  • Explain how conditional statements and loops evaluate rules to perform different coding actions.
  • Program the Agent using chat commands and loops to solve mazes, harvest wood, or build structures.
  • Apply cause-and-effect reasoning to code an if-statement that spawns an animal when its preferred crop is planted.
  • Differentiate between repeating structures such as forever loops, while loops, and if/else checks.

Blocks and items used in this lesson

Key vocabulary

Conditional
A coding statement that directs a program to perform different actions depending on whether a condition is true or false.
If / Else statement
A logic structure where one section runs if a condition is met, and the alternate section runs if it is not met.
While loop
A loop that continuously executes code only while a designated condition remains true.
Forever loop
A loop that continuously repeats the enclosed code indefinitely.

Before class

Lesson sequence

Suggested timing: about 60 minutes in total.

  1. Warm-up: Real-World Conditions10 min

    Introduce conditional logic through familiar scenarios. Ask students about household chores required to earn an allowance, conditions required to earn promised rewards (such as all As), or requirements needed to complete video game objectives.

  2. Skill Tutorials: Agent Coding20 min

    Direct learners to select their preferred programming language (Blocks, JavaScript, or Python) and choose a tutorial level:

    • Novice (Agent Maze): Program the Agent to navigate through a maze using chat commands and an if/else loop.
    • Intermediate (Chopping Trees): Automate tree chopping with chat commands and loops.
    • Expert (Agent Pyramid): Code the Agent to build a pyramid using loops.
  3. Application: Crop and Creature Enclosures20 min

    Students enter the Language Arts application area and explore various enclosures. Learners read the signpost at each enclosure to identify which crop is requested, then write an if-statement ensuring that when the correct crop is planted, the corresponding animal spawns.

  4. Reflection and Assessment10 min

    Conclude with a class discussion reinforcing key coding vocabulary. Review what forever loops do, how while loops function, and confirm that the else portion of an if/else block only runs when the initial condition is not met.

Assessment: success criteria

  • Student successfully codes the Agent using chat commands and loops to complete a tutorial task.
  • Student reads enclosure signs and writes an if-statement that links a planted crop to an animal spawn.
  • Student correctly explains the difference between a while loop and an if/else conditional check during reflection.

Differentiation

Support

Allow students who need assistance to begin with the Novice Agent Maze tutorial using block-based coding before tackling text syntax.

Stretch

Encourage advanced learners to complete all three tutorials across both JavaScript and Python before starting the enclosure challenge.

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 does a conditional statement do in a computer program?

  2. 2In an if / else structure, when does the else portion run?

  3. 3How does a while loop operate?

  4. 4What is the primary function of a forever loop?

  5. 5In the Language Arts enclosure activity, what action triggers an animal to spawn?

Resources

Part of the Coding Tutorials curriculum

This is lesson 3 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 can students choose from?

Students can work in MakeCode using visual Blocks, JavaScript, or Python depending on their comfort level and experience.

Can students complete more than one tutorial during the lesson?

Yes. Students may select an individual tutorial suited to their skill level or choose to complete all three tutorials before moving on to the enclosure activity.

How does this lesson connect computer science with reading and writing?

Students practice cause-and-effect reasoning by reading informative signs at animal pens and translating those written requirements into conditional if-statements.

Adapted from Conditionals 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