Skip to content
Computing · Year 7 · Computational Thinking and Logic · Autumn Term

Variables: Storing Data

Students will learn to declare, assign, and use variables to store and manipulate data in a program. Includes the concept of variable naming, data types, and updating values during program execution.

National Curriculum Attainment TargetsKS3: Computing - Programming and Development

About This Topic

Variables enable programs to store and update data, such as a game score or player name. Year 7 students declare variables in Scratch with clear names, assign initial values, and modify them during execution. They distinguish data types like numbers for scores and strings for text, and observe how updates alter program flow. This meets KS3 Computing standards for programming and development.

In the Computational Thinking and Logic unit, variables track dynamic states, like accumulating points in a game. Students design Scratch programs to keep score and analyse how value changes impact behaviour, fostering prediction and debugging skills essential for algorithm creation.

Active learning suits this topic perfectly. Students code and test variables hands-on in Scratch, gaining immediate feedback as scores update on screen. Pair programming and group challenges turn abstract storage into visible, interactive results, building confidence through experimentation and shared problem-solving.

Key Questions

  1. Explain how variables can be used to track the state of a game.
  2. Design a Scratch program that uses a variable to keep score.
  3. Analyze the impact of changing a variable's value on the behaviour of a running program.

Learning Objectives

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

Before You Start

Introduction to Programming Concepts

Why: Students need a basic understanding of what a program is and how instructions are executed sequentially.

Sequencing Instructions

Why: Understanding that programs run step-by-step is fundamental to grasping how variable values change over time.

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.

Watch Out for These Misconceptions

Common MisconceptionVariables hold permanent values that cannot change.

What to Teach Instead

Variables update dynamically; pair coding where students increment scores repeatedly demonstrates this. Discussions after testing help students articulate why mutability supports interactive programs like games.

Common MisconceptionVariable names do not affect program function.

What to Teach Instead

Clear names aid understanding, though function stays same; group renaming relays show how poor names cause confusion in collaboration. Students compare before-and-after code to value readability.

Common MisconceptionAny data type fits every variable.

What to Teach Instead

Scratch variables expect specific types; whole-class demos of string-in-number errors prompt predictions. Active fixes reinforce type awareness and prevent runtime surprises.

Active Learning Ideas

See all activities

Real-World Connections

  • Video game developers use variables extensively to track player health, ammunition counts, scores, and enemy positions in games like 'Minecraft' or 'Fortnite'.
  • App developers for mobile devices utilize variables to store user preferences, login details, and temporary data, ensuring a personalized and functional user experience.

Assessment Ideas

Exit Ticket

Provide students with a short Scratch code snippet that uses a variable. Ask them to write down: 1. What is the name of the variable? 2. What is its initial value? 3. What will its value be after the code runs?

Quick Check

Ask students to hold up fingers to represent data types: 1 for number, 2 for string. Then, present scenarios like 'player name', 'score', 'dialogue text', and have them indicate the correct type. Follow up by asking them to explain their choice.

Discussion Prompt

Pose the question: 'Imagine you are making a simple quiz game. What variables would you need to create, and what kind of data would each variable store?' Facilitate a brief class discussion, noting student ideas on the board.

Frequently Asked Questions

How do you introduce variables in Year 7 Scratch lessons?
Start with relatable analogies like a scoreboard in football, then demo declaring a score variable in Scratch. Have students assign zero, change on events like sprite clicks, and display it. Follow with guided pairs building a point collector, ensuring all see instant updates. This scaffolds from concrete to abstract, aligning with progression in computational thinking.
What are common errors when teaching variables?
Students often forget to initialise variables, leading to zero defaults, or misuse types like assigning text to numbers. They may also overlook scope, thinking changes affect all sprites. Address via debug stations where pairs trace errors step-by-step, logging fixes. Regular 'show variable' checks build habits for reliable code.
How can active learning help students understand variables?
Active approaches like live Scratch editing let students manipulate variables and witness real-time effects, such as score jumps in games. Collaborative challenges, like relay coding, encourage explaining updates to peers, clarifying concepts. Prediction demos before reveals activate prior knowledge, while individual debugging cements personal mastery through trial and error.
Why use variables to track game states?
Variables maintain dynamic information like lives or levels across program runs, enabling responsive games. In Scratch, they centralise data changes, simplifying complex logic. Students designing score keepers see how one update ripples through behaviours, mirroring professional programming and preparing for algorithms in later units.