Skip to content

Week 23 — Functions — naming your own instructions

At a glance

Date Friday, February 12, 2027
Unit 3 — From Blocks to Text
Big idea Functions let programmers name a set of instructions and reuse it.
Goal Students define and call a short Python function that makes their program easier to read or reuse.
Student accounts needed None. MakeCode Arcade runs in the browser without sign-in.
Prep time 5 minutes

Why this lesson looks the way it does

Functions can sound abstract, so today a function is simply 'name your own instruction.' That phrase works for younger students and remains accurate for older students. The common trap is defining a function and forgetting to call it, so the lesson models that mistake on purpose.

The mixed-age strategy stays explicit: Starters never face a blank page, Builders work from a template, and Extenders add features or write from scratch. Driver/Navigator pairing is not just classroom management here; it shares the typing load and makes students verbalize syntax.


CSTA 2026 standards

Concept area Connection
Algorithms & Design Students design, test, and revise small programs within constraints
Programming Students read and write Python syntax for the week's concept
Data & Analysis Students use program output or test results as evidence
Systems & Security Students work in no-account browser tools and avoid private information
Computing & Society Students explain technical work clearly to an audience

"I can…" objectives

By the end of today, students can say:

  • I can read the main Python pattern for today's lesson.
  • I can make and test a small change to working code.
  • I can explain one important line to my partner.
  • I can use evidence from running the code before claiming it works.

Teacher prep — the 5-minute version

  1. Open https://arcade.makecode.com and switch to Python.
  2. Paste the mini-lesson code below and run it once.
  3. Put this on the board: Run → Predict → Change one thing → Test.
  4. Pair students Driver/Navigator and plan the 0:24 swap.
  5. Keep Week 18–22 examples nearby for students who need a remix base.

Minute-by-minute run sheet

0:00–0:04 — Anchor

"Last Friday we used lists and loops to handle many values. Today we keep building in Python, but the win is still the same: understand a small program well enough to change it and test it."


0:04–0:12 — Mini-lesson

Run this, then remove the final cheer() and run again.

hero = sprites.create(img("""
    . 8 8 .
    8 8 8 8
    . 8 8 .
"""), SpriteKind.player)

def cheer():
    hero.say_text("You can do it!")
    pause(800)
    hero.say_text("Again!")

cheer()

"Defining the function is like writing a recipe. Calling the function is like cooking it. A recipe sitting in a book does not make dinner."


0:12–0:36 — Paired build

"Driver, type only what your pair understands. Navigator, your job is to stop the pair from making five changes before testing one."

Tiered challenges

🟢 Starter (grades 5–6): modify working starter code

Change the function messages, then call it.

hero = sprites.create(img("""
    . 8 8 .
    8 8 8 8
    . 8 8 .
"""), SpriteKind.player)

def cheer():
    hero.say_text("Great job!")
    pause(800)
    hero.say_text("Keep going!")

cheer()

🟡 Builder (grades 7–8): write from a template

Call the same function from a button press.

hero = sprites.create(img("""
    . 4 4 .
    4 4 4 4
    . 4 4 .
"""), SpriteKind.player)

def report():
    hero.say_text("Status: OK")
    pause(500)
    hero.say_text("Ready")

def on_a_pressed():
    report()
controller.A.on_event(ControllerButtonEvent.PRESSED, on_a_pressed)

🔴 Extender (grades 9–10): write from scratch or add features

Use a function with a parameter.

hero = sprites.create(img("""
    . 2 2 .
    2 2 2 2
    . 2 2 .
"""), SpriteKind.player)

def say_status(status):
    hero.say_text("Status: " + status)

say_status("ready")

Add buttons that call say_status with different messages.


0:36–0:42 — Share-out

"Tell us the name of your function. Then tell us where you called it. Those are two different places."


0:42–0:45 — Teaser + prompt

"Next Friday we break code on purpose and learn to read the error message like a clue."

🤔 Think About This

Notice a named routine this week: a recipe, play call, classroom procedure, or morning routine. What steps hide inside that name?


Share-out prompt

"Tell us the name of your function. Then tell us where you called it. Those are two different places."


🔌 Unplugged Plan B — if the internet is down

Time Activity
0:00–0:04 Same anchor: connect to last Friday and name today's target.
0:04–0:12 Board model with paper code cards. Underline names, circle punctuation, and box indented blocks.
0:12–0:26 Pairs run a paper "human interpreter" trace. One student reads exactly; one student records output or error.
0:26–0:36 Pairs modify one card, trade with another pair, and test again.
0:36–0:42 Share one working change and one bug found by reading carefully.
0:42–0:45 Same teaser and Think About This.

Common problems & fixes

Problem What students may see Fix
Missing colon after def cheer() SyntaxError: expected ':' Add : at the end of the function definition.
Function body not indented IndentationError: expected an indented block after function definition Indent the lines inside the function.
Forgetting to call the function no error Add cheer() after the definition or inside an event.
Calling before defining NameError: name 'cheer' is not defined Put the def block above the first call.
Function name misspelled NameError: name 'cherr' is not defined Match spelling exactly, including underscores.

Vocabulary

  • Function — a named group of instructions
  • Define — teach Python what a function means
  • Call — run a function
  • Parameter — information given to a function
  • Decomposition — breaking a program into smaller parts

Reflection — fill in after class

  • Which students could explain their code without prompting?
  • Which syntax issue slowed the room down?
  • Did pairs test one change at a time?
  • What should carry into next week?

Next week: Week 24 — Debugging — reading an error message on purpose