Level 5

Show the Numbers

Level 5 · Chapter 7

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Algorithms & Programming · Grades 6–8

Combine loops and conditions, even nested ones.

Code 2-AP-12Read the official text

Also practised: 2-AP-17

Common Core State Standards for Mathematics

Expressions & Equations · Grade 6

Use a letter for a number that can change.

Code 6.EE.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 control which variable monitors appear on screen and when.

1👋 Warm-Up

For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 2
✦ CSTA 2-AP-12 · CSTA 2-AP-17 · ISTE 1.5.c · Standards
🎯 I cancontrol which variable monitors appear on screen and when
🧩 New blocks2 blocks
📝 New words7 words
⏱ Lesson time~40 min
Teacher Guide

📋 Before class

⚠️ Common misconceptions

  • Students think show variable and hide variable affect the variable's value. They only affect whether the monitor is visible — the value continues updating invisibly.
  • Students think the checkbox and show/hide variable are separate switches. They control the same monitor — running show variable ticks the checkbox too.
  • Students think hide variable works like deleting the variable. The variable still exists and updates — it just isn't shown.

🎯 Differentiation

🐢 Struggling: Start with just show variable [score ▾] and hide variable [score ▾] triggered by key presses. Confirm the value is still updating even when hidden.

🚀 Advanced: Challenge them to build a full debug overlay: 5 variables (x, y, speed, lives, state), all hidden by default, all toggled on/off with one key. Use a single boolean variable to track debug state.

💡 During the lesson

  • Warm-UpAsk: "What information do you want to see when you play a game? What information would be annoying if it always showed?" This motivates the idea that UI design is a deliberate choice — not just "show everything all the time." A variable's scope 🔭 is where it is visible — every sprite, or just one.
  • Try ItDemonstrate the hidden-but-updating behavior live. Hide the score monitor, let it run for 5 seconds, then show it — the number will have changed even though the box was invisible. This is the most important concept to nail before the build.
    The first experiment shows the value at the end — proving hidden variables keep updating. In the second experiment, wait 0 looks the same as the first: the new show-variable is undone at once by the hide-variable, so the box never appears until the end. The third experiment is the most important: with debug_mode 0, the variable IS still updating to 10, but the student cannot see it. Use the variable list checkbox to confirm the hidden value.
  • PlanThe flowchart has several concurrent scripts. Walk through each lane separately before students build. Emphasize that "hide variable" at game over is a UI decision — the variables still have values (score = X, lives = 0). A real game might save those values to a leaderboard after hiding them.
  • BuildStep 6 introduces a 1-second wait after each hit — this is the "invincibility window" common in all platformer games. Ask: "Why do we need this wait? What would happen without it?" (Pico would lose all 3 lives in one collision because the touching condition stays true for many frames.)