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.
Learning Objectives
- 1Design a Scratch program that uses a variable to store and update a user's score.
- 2Explain how changing a variable's value affects the execution flow of a simple program.
- 3Identify appropriate data types (e.g., number, string) for different kinds of information stored in variables.
- 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 →
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
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
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
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
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
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
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.
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.
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
| variable | A named storage location in a program that holds a value which can change during program execution. |
| declaration | The process of creating a variable and giving it a name, often before assigning it a value. |
| assignment | The act of giving a variable a specific value, which can be done when it is declared or later in the program. |
| data type | A classification of data that tells the computer how to interpret the value stored in a variable, such as a number or text. |
| update | To change the value stored in a variable to a new value during the running of a program. |
Suggested Methodologies
More in Computational Thinking and Logic
Efficiency and Optimisation
Exploring how to evaluate algorithms for efficiency and identify opportunities for optimisation.
2 methodologies
Logic Gates: AND, OR, NOT
Introduction to fundamental logic gates and their truth tables as building blocks of digital circuits.
2 methodologies
Boolean Logic and Expressions
Understanding Boolean operators and writing simple Boolean expressions to represent conditions.
2 methodologies
Introduction to Block Programming (Scratch)
Students will be introduced to the Scratch interface and basic block programming concepts.
2 methodologies
Sequence: Order of Instructions
Mastering the order of execution and using repetition to make code more efficient.
2 methodologies
Ready to teach Variables: Storing Data?
Generate a full mission with everything you need
Generate a Mission