Level 4

Build Your Own Block

Level 4 · Chapter 5

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Algorithms & Programming · Grades 6–8

Write a function with inputs so you can reuse it.

Code 2-AP-14Read the official text

Common Core State Standards for Mathematics

Operations & Algebraic Thinking · Grade 5

Write and read number expressions.

Code 5.OA.A.2Read the official text

The short lines are our own words. We matched this lesson to these standards ourselves; the standards' owners have not reviewed or endorsed this course.

Common Core State Standards © 2010 National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.

Today you will define reusable code with a custom block (no parameters).

1👋 Warm-Up

For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 2
✦ CSTA 2-AP-14 · ISTE 1.5.c · Standards
🎯 I candefine reusable code with a custom block (no parameters)
🧩 New blocks2 blocks
📝 New words6 words
⏱ Lesson time~35 min
Teacher Guide

📋 Before class

⚠️ Common misconceptions

  • Students think the define block runs automatically. It does not. The define block only stores the instructions. You must call the custom block to run them.
  • Students put the define block inside another script. The define block must stand alone with its body — it is not placed inside a forever or when flag clicked.

🎯 Differentiation

🐢 Struggling: Use a physical analogy: a recipe card (define) vs. cooking (calling). Write the recipe, then follow it. Show the define block alone, then the call block in the main script.

🚀 Advanced: Define a second custom block called walk-triangle. Call both walk-square and walk-triangle from the main script so the cat walks two different paths.

💡 During the lesson

  • Warm-UpAsk: "If a video game character has a jump animation with 6 steps, and the character can jump 50 times in a game — how many times would you write those 6 steps without custom blocks?" (300 times.) Custom blocks reduce this to 6 + 50 calls. A custom block is a procedure 📜 — a named set of steps you can run anytime.
  • Try ItProject the second experiment. Count the blocks: without a custom block, 3 × 3 = 9 blocks for the body. With it, 4 (define) + 3 (calls) = 7 blocks. Ask: "Which is easier to fix if you want the side length to change?" (The custom block — edit once, all 3 calls update.) The Xy-grid backdrop lets students trace the cat's square path with a finger.
    The first experiment with 0 calls is the most important. Students see the define block exists, but nothing happens — proving that define alone does not run. The call is required. Ask: "What is missing with 0 calls?" (The call.)
  • PlanThe flowchart separates the define (written once, shown as its own lane) from the main flow (4 calls). Students should see that the define is not inside the main flow — it is a separate definition that the main flow uses by name.
  • BuildStep 10 is the key payoff demonstration. Students who change the move value in the define once and see the whole four-lap walk resize on the next run experience the power of the abstraction — one edit, every call changes. This moment builds deep understanding of why custom blocks exist.