Lesson plan

Variables

Learn coding variables in MakeCode, then collect biome resources and adjust code variables to build a sustainable cabin with the Agent.

Variables
Ages
Ages 8-18
Essential question

How can we use variables in code to design and build a structure suited to its natural environment?

Overview

In computer science, a variable represents a labeled location in memory used to store values that can change during execution. By pairing variables with loops and commands, programmers can streamline repetitive actions and dynamically alter how a program operates. This lesson introduces learners to variables across multiple difficulty tiers and programming languages, including block-based coding, JavaScript, and Python.

Students begin by selecting coding tutorials that match their skill level, practicing commands such as teleportation, filling spaces, and printing text with variables. They then apply their understanding to an environmental challenge: evaluating biome conditions, gathering appropriate natural resources across different sites, and configuring variable parameters (dimensions, block types, and coordinates) in starter code to construct a sustainable cabin.

Learning objectives

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

  • Define what a variable is in computer science and identify how its stored value can vary.
  • Manipulate code variables such as length, width, height, material type, and coordinates in MakeCode.
  • Evaluate biome conditions and gather natural resources that support sustainable construction.
  • Execute starter code using the Agent or Builder to construct a cabin that fits local topography.

Blocks and items used in this lesson

Key vocabulary

Variable
A named space in computer memory that stores data which can change during a program.
Sustainability
Meeting current human and environmental needs without compromising the ability of future generations to meet theirs.
Declaring a Variable
Creating a variable and using an assignment operator to store an initial value in it.
Coordinates
A set of values (x, y, z) that define a specific physical position in the Minecraft world.

Before class

Lesson sequence

Suggested timing: about 70 minutes in total.

  1. Concepts of Variables and Sustainability10 min

    Introduce the term variable as a memory location for data that changes, using common examples like count, x, y, and z. Discuss how pairing variables with loops eliminates repetitive manual actions.

    Connect coding parameters to sustainability by discussing real-world resource balance, such as rainforest loss impacting rivers and food supplies, or matching building materials to local climates.

  2. Skill Tutorials in MakeCode20 min

    Allow students to choose their preferred programming language (Blocks, JavaScript, or Python) and select one or more tutorials based on their experience:

    • Tutorial 1: Mega Jump (Novice) - Use teleport commands and coordinates to leap great distances.
    • Tutorial 2: Bat Cave (Intermediate) - Combine repeat and fill commands to carve an underground cavern and spawn bats.
    • Tutorial 3: Letter Printing (Expert) - Create multiple variables to print block letters and words at target locations.
  3. Biome Resource Expedition15 min

    Direct students to inspect their starting build site to examine topography, weather, and biome conditions. Students then travel to four separate resource locations across the world.

    Each location contains four to five resource types, but only one or two are suitable for construction. Students must decide which materials to harvest and return with to the build site.

  4. Sustainable Cabin Construction15 min

    Students open the starter build code to direct their Agent or Builder to erect a cabin. They must edit the code's variables to reflect their expedition:

    • Modify length, width, and height to match the quantity of collected blocks.
    • Assign the type variable to match the specific materials gathered.
    • Adjust the x, y, z coordinates so the structure fits the site's topography sustainably.
  5. Review and Discussion10 min

    Gather students to assess their builds and discuss the coding process. Ask students to identify which variables they edited and how environmental limits directly constrained their dimensions and location choices.

Assessment: success criteria

  • The student can define a variable and explain how the assignment operator stores data in memory.
  • The student modifies the length, width, height, material type, and coordinate variables within the provided starter code.
  • The constructed cabin matches the volume and type of materials collected during the expedition.
  • The student explains how site topography and limited resources constrained their variable values.

Differentiation

Support

Have learners begin with the Novice Mega Jump tutorial using block-based code before editing numerical values in the cabin starter script.

Stretch

Challenge advanced students to complete all three tutorials using text-based JavaScript or Python before coding their cabin.

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 the primary definition of a variable in computer science?

  2. 2Which of the following represents an example of sustainable decision-making?

  3. 3How does a programmer declare a variable in the coding editor?

  4. 4In the cabin construction project, what constrained the length, width, and height variables?

  5. 5Why must students adjust the coordinate variables (x, y, z) for their build site?

Resources

Part of the Coding Tutorials curriculum

This is lesson 9 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 use in this lesson?

Students can complete the coding activities using Blocks, JavaScript, or Python within the MakeCode editor.

Do students need to finish all three tutorials before building?

No, students may choose a single tutorial matching their experience level or work through all three before starting the application project.

How many items should students take from each expedition site?

Although each site contains four to five items, students should evaluate the environment and collect only the one or two items suitable for the final build site.

Adapted from Variables by Minecraft Education on Minecraft Education, last updated Jul 2, 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