Skip to content

Variables: Storing DataActivities & Teaching Strategies

Active learning works for variables because students need to experience data changing in real time. When Year 7 students write code that updates a variable continuously during Pairs Coding, they see firsthand how mutability supports interactive programs like games. This hands-on approach builds mental models that abstract explanations alone cannot.

Year 7Computing4 activities20 min35 min

Learning Objectives

  1. 1Design a Scratch program that uses a variable to store and update a user's score.
  2. 2Explain how changing a variable's value affects the execution flow of a simple program.
  3. 3Identify appropriate data types (e.g., number, string) for different kinds of information stored in variables.
  4. 4Analyze the role of variables in tracking the changing state of a game or simulation.

Want a complete lesson plan with these objectives? Generate a Mission

30 min·Pairs

Pairs Coding: Score Tracker

Students pair up in Scratch to create a simple game sprite that awards points on touch. One partner declares a score variable, sets it to zero, and adds change block for increments; the other shows it forever on stage. Pairs test, switch roles, and predict outcomes of doubling points.

Prepare & details

Explain how variables can be used to track the state of a game.

Facilitation Tip: During Pairs Coding: Score Tracker, circulate and ask each pair to explain why their score variable updates correctly after each step.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
25 min·Small Groups

Small Groups: Variable Naming Relay

Divide class into small groups with code snippets using poor variable names like 'x' for player health. Groups rewrite with descriptive names, then pass to next group to add updates and test in Scratch. Discuss readability improvements as a class.

Prepare & details

Design a Scratch program that uses a variable to keep score.

Facilitation Tip: In Variable Naming Relay, give each group only three minutes per rename to simulate real-world constraints and spark urgency.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
20 min·Whole Class

Whole Class: Prediction Demo

Project a Scratch program with a hidden variable for countdown timer. Class predicts display changes as you update it live, then replicate individually. Vote on predictions before reveals to build anticipation and analysis.

Prepare & details

Analyze the impact of changing a variable's value on the behaviour of a running program.

Facilitation Tip: For the Prediction Demo, pause execution midway and ask students to predict the next value before running the block, reinforcing cause-effect links.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
35 min·Individual

Individual: Debug Challenge

Provide Scratch files with variable errors, like uninitialised scores or type mismatches. Students fix alone, run tests, and note fixes in journals. Share one solution per student in plenary.

Prepare & details

Explain how variables can be used to track the state of a game.

Facilitation Tip: During Debug Challenge, provide a sample wrong-type error and have students vocalize the mismatch before fixing it.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills

Teaching This Topic

Teach variables by modeling live mutations in front of students, narrating why each change matters. Avoid metaphors like boxes—students need concrete evidence that variables are memory locations holding changing data. Research shows that students grasp mutability faster when they debug their own errors, so plan for safe, scaffolded missteps. Emphasize naming as part of design, not decoration, by requiring students to justify their labels during peer reviews.

What to Expect

By the end of the lesson, students will confidently declare variables with meaningful names, assign appropriate data types, and modify values during execution. They will explain why clear naming and type awareness matter for program clarity and function. Observations of their debugging and naming choices will show growing independence.

These activities are a starting point. A full mission is the experience.

  • Complete facilitation script with teacher dialogue
  • Printable student materials, ready for class
  • Differentiation strategies for every learner
Generate a Mission

Watch Out for These Misconceptions

Common MisconceptionDuring Pairs Coding: Score Tracker, watch for students who assume the variable holds a fixed value and do not update it during the loop.

What to Teach Instead

Pause pairs midway and ask them to verbalize the current value of their score variable before and after the update block; prompt them to trace the flow step-by-step.

Common MisconceptionDuring Variable Naming Relay, watch for students who rename variables without considering clarity or collaboration.

What to Teach Instead

Require each group to present their new names and justify them to the class, highlighting how poor names make code harder to maintain.

Common MisconceptionDuring Prediction Demo, watch for students who assume any data can be stored in any variable regardless of type.

What to Teach Instead

Show a string-in-number error in the demo, then have students predict what will happen before running the block and discuss how Scratch enforces types.

Assessment Ideas

Exit Ticket

After Pairs Coding: Score Tracker, give students a short Scratch snippet with a variable. Ask them to write: 1. The variable’s name, 2. Its initial value, 3. Its value after the code runs.

Quick Check

During Variable Naming Relay, present scenarios like 'player name', 'score', 'dialogue text' and have students hold up fingers (1 for number, 2 for string) before revealing the correct answer and asking them to explain their choice.

Discussion Prompt

After the Prediction Demo, pose: 'Imagine a simple quiz game. What variables would you create and what data types would they store?' Facilitate a brief discussion and note ideas on the board.

Extensions & Scaffolding

  • Challenge: Ask students to add a second variable that tracks lives remaining, then modify the score update to subtract lives when the score exceeds 100.
  • Scaffolding: Provide starter code with the variable already declared and named, so students focus on the logic of updates and data types.
  • Deeper: Invite students to design a mini-game where three variables interact: score, lives, and a timer, then test each other’s projects.

Key Vocabulary

variableA named storage location in a program that holds a value which can change during program execution.
declarationThe process of creating a variable and giving it a name, often before assigning it a value.
assignmentThe act of giving a variable a specific value, which can be done when it is declared or later in the program.
data typeA classification of data that tells the computer how to interpret the value stored in a variable, such as a number or text.
updateTo change the value stored in a variable to a new value during the running of a program.

Ready to teach Variables: Storing Data?

Generate a full mission with everything you need

Generate a Mission