Level 3

My First Variable

Level 3 · Chapter 1

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Algorithms & Programming · Grades 3–5

Use a variable to keep a number and change it.

Code 1B-AP-09Read the official text

Also practised: 1B-AP-11 · 1B-AP-15

Common Core State Standards for Mathematics

Operations & Algebraic Thinking · Grade 4

Find factors and multiples.

Code 4.OA.B.4Read 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 create a variable and change its value.

1👋 Warm-Up

For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 1B
✦ CSTA 1B-AP-09 · CSTA 1B-AP-11 · CSTA 1B-AP-15 · ISTE 1.5.a · Standards
🎯 I cancreate a variable and change its value
🧩 New blocks2 blocks
📝 New words7 words
⏱ Lesson time~40 min
Teacher Guide

📋 Before class

⚠️ Common misconceptions

  • Students may think the variable always starts from zero — it keeps its last value unless reset with 'set to 0'.
  • Students may confuse 'set to' (replace) with 'change by' (add). Show them side by side.

🎯 Differentiation

🐢 Struggling: Provide a labeled diagram: a box with '📦 score' on the outside and '0' inside. Have them draw it on paper first.

🚀 Advanced: Challenge them to make two variables — one for score, one for lives — and decrease lives when touching the edge.

💡 During the lesson

  • Warm-UpDraw a simple box on the board. Write "score" on the outside and "0" inside. Ask: "If I scored 1 point, what number goes inside now?" (1.) If I scored again? (2.) This is exactly what change [score ▾] by (1) does. A variable is a box that can store 💾 a number or word.
    Point to each frame and ask: "What number is in the box now?" Students chant the values together. Reinforce that the box (variable) updates every time the cat moves.
  • Try ItHold up set [score ▾] to (0) and change [score ▾] by (1) side by side. "Set" replaces the number. "Change" adds to it. The forever block (from earlier) wraps blocks so they repeat without stopping.
    Run the first experiment first — students see the start number go into the box, then grow by 1. Run the second — with 5 the score jumps by 5 each step, and with -1 it falls. Run the third — the score climbs to 10, then set throws the 10 away. Then, in Scratch, run the script without the set block twice — the second click shows the score keeps growing from last time (no reset). This makes the role of set [score ▾] to (0) visible. Positive numbers increase, negative numbers decrease — try change [score ▾] by (-1) as a bonus.
  • PlanAfter students fill the plan boxes, ask: "Why do we reset the score FIRST?" (So it does not keep adding from last time.) This is a key sequencing concept. Point out that the storyboard and the flowchart show the SAME plan two ways — the flowchart is the grown-up version they will use more from now on.
  • BuildWalk the room after step 2 — many students will not see the variable appear on the screen. Point it out: "Do you see the orange box in the top-left corner? That is your variable on display." Also watch for students who skip step 4 — the reset — and see unexpected scores.