Lesson plan

Python 101 with MakeCode - Lesson 6

Program the CodingMine Agent to navigate roads, read traffic signs, and avoid obstacles using Python conditionals, if-elif-else logic, and Boolean operators.

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

How can programmers use conditionals and Boolean logic to help an autonomous vehicle make safe navigation decisions?

Overview

In this lesson, students explore decision-making in computer programming by helping the CodingMine team train their autonomous driving Agent. To prepare the Agent for self-driving scenarios, learners study how to test conditions in code and determine specific actions based on incoming data from the environment.

Students work in a simulated traffic world within Minecraft Education, using Python conditionals and Boolean logic. As they progress through three hands-on challenges, they program the Agent to recognize traffic lights, interpret turn signs, and safely maneuver around randomly placed road obstacles.

Learning objectives

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

  • Explain how Boolean logic represents conditions as true or false
  • Construct if, if-else, and elif conditional statements in Python
  • Apply comparison operators such as == and the logical operator AND to evaluate conditions
  • Program the Agent to detect colors, follow simulated road signs, and navigate around obstacles

Blocks and items used in this lesson

Key vocabulary

Conditional
A programming command that runs specific code only when a specified condition evaluates to true or false.
Boolean Logic
A system of logic where values evaluate to either true (represented by 1) or false (represented by 0).
Comparison Operator (==)
A syntax symbol used to compare a defined value against a game state or coding outcome.
AND Operator
A logical operator that verifies whether two separate conditions are both true before executing an action.

Before class

Lesson sequence

Suggested timing: about 60 minutes in total.

  1. Concept Introduction10 min

    Introduce the lesson scenario: CodingMine needs help preparing their Agent to operate as a self-driving car. Use the accompanying presentation to present conditionals, the if, if-else, and elif structure, and Boolean logic (where 1 represents true and 0 represents false).

    Explain how the double equals operator (==) compares conditions and how the AND operator checks that two separate conditions are met.

  2. Activity 1: Stop and Go15 min

    Direct students to help the Agent interpret simulated traffic lights along a track:

    • Part 1: Code the Agent to continue moving forward whenever green blocks are detected to its left.
    • Part 2: Program the Agent to halt when a red block appears to its left.
    • Part 3: Add logic so the Agent pauses for 2 seconds upon detecting a yellow block to its left before continuing toward the gold finish.
  3. Activity 2: Is It Left or Right?15 min

    Challenge students to program the Agent to navigate simulated city streets. Students write conditional logic that reads road signs placed along the route, directing the Agent to stop and turn left or right according to the sign instructions.

  4. Activity 3: Getting Through15 min

    Students write obstacle detection code that guides the Agent across a simulated course containing randomly positioned blocks. When the Agent detects a block, that block is highlighted, and the Agent must find a clear path to reach the finish regardless of block positions.

  5. Review and Formative Assessment5 min

    Gather the class to reinforce key computational concepts. Ask students the lesson check questions regarding Boolean 1 and 0 values, conditional definitions, the AND operator, and the double equals syntax.

Assessment: success criteria

  • The Agent correctly identifies green, yellow, and red blocks to continue, wait 2 seconds, or stop.
  • The Agent successfully evaluates road sign conditions to make correct turns along the course.
  • The Agent detects, highlights, and bypasses randomly placed obstacle blocks to reach the goal.
  • The student correctly explains the function of the == comparison operator and the AND logical operator during discussion.

Differentiation

Support

Walk through the syntax of the if-elif-else statements using the presentation slides before students code the traffic light and road sign checks.

Stretch

Encourage students to optimize their obstacle avoidance code in Activity 3 to handle any unexpected layout of obstacle blocks with minimal repeated commands.

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. 1In Boolean logic, what do the values 1 and 0 represent?

  2. 2What is the primary function of a conditional statement in Python?

  3. 3What does the AND operator check in a conditional statement?

  4. 4What does the double equals syntax (==) do in code?

  5. 5In Activity 1, how is the Agent programmed to respond to a yellow block on its left?

Resources

Part of the Python 101 curriculum

This is lesson 6 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

What curriculum materials support this lesson?

This lesson includes an educator guide, a step-by-step classroom presentation using the gradual release model, and a Curriculum Overview found under the Supporting Files section.

What age group is this lesson intended for?

The lesson is structured for intermediate coders aged 11-13, 14-18, and 18+, with curricular alignment notes specifically provided for Upper Secondary students in grades 9-12.

Adapted from Python 101 with MakeCode - Lesson 6 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