Lesson plan

Functions

Students learn to create and name functions in MakeCode to direct their Agent and build a multi-use city block adhering to municipal height rules.

Functions
Ages
Ages 8-18
Essential question

How can using functions streamline repetitive coding tasks and help us build organized community spaces?

Overview

In computer programming, functions bundle a sequence of instructions into a single, reusable command. This lesson introduces learners to breaking down everyday and digital processes into smaller, repeatable actions. By learning how to define and name functions, students discover how structured code minimizes repetition, increases clarity, and makes troubleshooting errors much simpler.

Using the MakeCode editor alongside Minecraft Education, students choose their preferred coding language—Blocks, JavaScript, or Python—and advance through scaffolded tutorials. They then apply their programming knowledge to a community development challenge, using their Agent and custom functions to construct a multi-use city block for Craftcity that follows local building regulations.

Learning objectives

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

  • Define a function as a reusable section of code that performs a distinct task.
  • Explain the importance of naming functions clearly to aid organization and debugging.
  • Program the Agent using functions in Blocks, JavaScript, or Python to complete construction tasks.
  • Design and build a multi-use city block model that satisfies local building height ordinances.

Blocks and items used in this lesson

Key vocabulary

Function
A named, defined section of code created to complete a specific task that can be easily reused.
Debugging
The process of identifying and correcting errors or unintended behaviors in computer code.
Ordinance
A local law or municipal rule, such as restrictions governing building heights.

Before class

Lesson sequence

Suggested timing: about 65 minutes in total.

  1. Guiding Questions and Warm-up10 min

    Lead a class discussion connecting daily habits to computer programming concepts:

    • Ask students to list routines they repeat daily that involve multiple smaller steps (e.g., tying shoes, writing their name, or stacking blocks to build a wall).
    • Introduce functions as named sets of instructions that allow coders to perform repeated actions efficiently without rewriting code.
  2. Tiered Coding Tutorials30 min

    Direct students into MakeCode to work through the skill tutorials using their choice of Blocks, JavaScript, or Python:

    • Tutorial 1: Agent Fun (Novice, ~5 min): Code the Agent and objects using basic functions.
    • Tutorial 2: Modifying Agent Fun (Intermediate, ~10 min): Modify existing code into different specialized functions.
    • Tutorial 3: House with Functions (Expert, ~15 min): Organize functions to command the Agent to build a complete house.
  3. Craftcity Design Challenge20 min

    Present the community planning scenario from Craftcity's mayor. Students must design a live, work, and play city block while programming the Agent with functions to complete the structure.

    Remind builders that city ordinances limit building height to 5 stories (a maximum of 25 blocks tall), requiring deliberate planning and precise function loops.

  4. Review and Discussion5 min

    Gather students to evaluate their work and reinforce core programming concepts:

    • Ask students how using functions simplified their construction scripts.
    • Discuss how grouping commands made it easier to locate mistakes and debug their programs.

Assessment: success criteria

  • Student accurately defines a function and explains how it simplifies code.
  • Student creates and assigns clear, descriptive names to functions in MakeCode.
  • Student commands the Agent to carry out building tasks through functional code.
  • Student completes a live, work, and play block model that remains at or under the 25-block height limit.

Differentiation

Support

Allow students to focus on the Novice tutorial in block coding, practicing one simple Agent movement function before attempting the build challenge.

Stretch

Challenge students to complete all three tutorials in Python or JavaScript and write automated multi-story building functions for Craftcity.

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 function in computer programming?

  2. 2How do functions assist a programmer when writing code?

  3. 3Which three coding languages can learners select within MakeCode for these tutorials?

  4. 4What height restriction does Craftcity enforce for the new city block?

  5. 5What model of city block must students build for the Craftcity challenge?

Resources

Part of the Coding Tutorials curriculum

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

Can students participate if they have never written text-based code before?

Yes. Students have the option to complete all tutorials and challenges using visual block-based coding in MakeCode before exploring JavaScript or Python.

Do students need to finish all three tutorials before starting the city project?

Not necessarily. The tutorials are tiered by difficulty (Novice, Intermediate, and Expert) so learners can practice at their current skill level or complete all three if time permits.

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