Skill

3.2.2 Variables, constants and assignment

GCSE Computer Science AQA

This resource focuses on 3.2.2 Variables, constants and assignment for AQA GCSE Computer Science. It sits within the programming section of the specification and covers one of those deceptively small topics that quietly appears everywhere: reading code, tracing code, writing pseudocode, and spotting why a program is behaving oddly. Students need to understand what kind of value should be stored, which values are allowed to change, which should stay fixed, and what an assignment statement is actually doing.

For teachers, this is often the point where students start treating assignment like ordinary algebra, assume every named value is basically the same thing, or decide a constant is just a variable wearing a more confident name. This guide keeps the focus tight: what AQA expects, how to teach it clearly, and how to mark answers without rewarding vague programming wallpaper.


At a Glance

🧭 Specification context: AQA GCSE Computer Science, 3.2.2 Programming

  • Students must know: what variables are, what constants are, what assignment means, and how named values are used clearly in algorithms and programs.

  • Key exam focus: defining terms precisely, tracing assignment statements, choosing whether a value should be variable or constant, and using meaningful identifiers.

  • Why it matters: this topic supports almost every later programming task because students cannot write secure code if they do not understand what values are being stored and updated.

  • Common student challenges: treating assignment as an equation, thinking constants are just “important variables”, confusing declaration with assignment, and assuming variables only store numbers.


Understanding the Topic

Where this fits in the specification

AQA expects students to have both a theoretical understanding and a practical understanding of programming content. For this topic, that means students should not only be able to define variables, constants, and assignment, but also recognise and use them accurately in pseudocode or program code. They should be comfortable reading statements, tracing changing values, and choosing sensible names and data types.

Variables

A variable is a named storage location whose value can change while a program runs. Variables are used when a program needs to keep track of information that might be updated, replaced, or calculated.

Typical classroom examples include:

  • a running total
  • a player's score
  • a student's age entered by the user
  • the number of items in a basket
  • a Boolean value such as isLoggedIn

A strong explanation goes beyond “it changes”. Students should understand that a variable stores a value in memory and that the program can update that value later.

Constants

A constant is a named value that does not change while the program runs. Constants are useful when a value should stay fixed throughout the program, because they make code clearer and reduce careless changes.

Good examples include:

  • a pass mark
  • the number of days in a week
  • VAT rate used in a calculation
  • a maximum class size
  • the value of pi in a simplified program

A useful teaching line is this: if the program should treat the value as fixed, students should treat it as fixed too.

Assignment

Assignment is the process of giving a value to a variable or constant. In pseudocode, this is often shown with the arrow symbol.

score ← 0
name ← "Aisha"
total ← price * quantity

The key idea is that the expression on the right is worked out first, and the result is stored in the identifier on the left.

That is why this statement is perfectly valid in programming:

score ← score + 1

It means:

  1. take the current value stored in score
  2. add 1
  3. store the new value back into score

This is often the moment where maths and programming have a slightly awkward meeting. In algebra it looks impossible. In programming it is standard and essential.

Declaration and data types

Students also benefit from understanding the difference between declaring a value and assigning a value.

  • Declaration gives a variable a name and, in some languages, a data type.
  • Assignment gives that variable its value.

Some programming languages require explicit declaration. Others do not. For AQA, students should still understand the idea clearly and use sensible identifiers and suitable data types.

What secure understanding looks like

By the end of teaching, students should be able to:

  • explain the difference between a variable and a constant
  • explain what assignment does in a statement
  • trace a value as it changes through several assignment statements
  • choose when a value should be variable and when it should be constant
  • use meaningful names rather than vague labels such as x or thing

Key Terms and Concepts

Term Teacher-ready explanation
Variable A named storage location whose value can change while a program runs.
Constant A named value that stays the same while a program runs.
Assignment Giving a value to a variable or constant.
Identifier The name given to a variable or constant, such as score or PASS_MARK.
Declaration Introducing a variable and, in some languages, specifying its data type before it is used.
Initialisation Giving a variable its first value, such as count ← 0.
Data type The kind of value being stored, such as integer, real, string, or Boolean.
Trace Following a program step by step to see how values change.

How to Teach This Topic

Teaching moves that work well

  • Start with memory boxes rather than code. Put labels such as score, name, and PASS_MARK on the board and ask what each box stores.
  • Sort values into can change and should stay fixed before introducing the words variable and constant.
  • Model assignment slowly using short examples such as total ← 5, then total ← total + 3.
  • Use trace tables early so students can see the value changing rather than guessing.
  • Make students explain code in words before writing code of their own.

Questions worth asking in class

  • Which value changes during the program?
  • Which value should stay fixed throughout?
  • What is being stored on the left-hand side?
  • What is being worked out on the right-hand side?
  • If this line runs twice, what changes?
  • Would a better identifier make the code easier to read?

A simple lesson sequence

  1. Introduce named values using everyday examples such as scoreboards, baskets, or login attempts.
  2. Teach variables and constants together so students compare them directly.
  3. Model assignment with one-step examples, then with updating statements such as count ← count + 1.
  4. Move quickly into short trace tasks.
  5. Finish with exam-style questions that ask students to explain, not just recognise.

Helpful scaffolds

  • Use sentence stems such as "A variable is..." and "This should be a constant because..."
  • Ask students to annotate each assignment with old value, calculation, and new value.
  • Give students mixed examples and ask them to identify whether each statement is assigning, comparing, or calculating.
  • Use colour coding: left-hand side in one colour, right-hand side in another.

Extension ideas

  • Give students a short algorithm and ask them to justify every identifier choice.
  • Ask students to improve poor identifiers such as x, a1, or num.
  • Challenge students to debug code where a constant has been treated like a variable or where the wrong variable is updated.

💡 Teacher tip: if students can say what the value was before the line, what the line does, and what the value is after the line, their tracing usually improves very quickly.


How to Mark This Topic Effectively

Feature What strong answers usually show What weak answers often do
Definition of variable States that it is a named storage location whose value can change during execution. Says only that it is “something that varies” or “a piece of data”.
Definition of constant Explains that the value stays fixed while the program runs. Calls it an “important variable” or just says it “does not move”.
Explanation of assignment Explains that the right-hand value is calculated first, then stored in the identifier on the left. Treats the statement like ordinary maths or only describes the symbol.
Use of examples Uses sensible identifiers such as score, name, or PASS_MARK. Uses vague examples that do not show understanding.
Tracing Follows value changes accurately from line to line. Loses track of old and new values or skips steps.

📝 Exam technique: if a student writes that score ← score + 1 is wrong because the value cannot equal itself plus one, they are reading it as algebra. Reward answers that recognise assignment as a programming instruction, not a mathematical claim.

Quick marking rules that help

  • Reward precision over vague familiarity.
  • If a response gives a correct example but a weak definition, do not assume the definition mark is secure.
  • Where a question asks students to explain an assignment statement, look for before, process, and after.
  • Meaningful identifier names are worth rewarding when they help make the logic clear.

Example Student Responses

Example question

Explain the difference between a variable and a constant. Then explain what happens in the statement score ← score + 1. [6 marks]

Marking guidelines

  • 2 marks for explaining that a variable stores a value that can change while the program runs
  • 2 marks for explaining that a constant stores a value that does not change while the program runs
  • 2 marks for explaining that the current value of score is read, 1 is added, and the new value is stored back in score
Strong response

A variable is a named storage location whose value can change while the program is running. A constant is a named value that stays the same during the running of the program. In the statement score ← score + 1, the computer takes the current value stored in score, adds 1 to it, and stores the new result back into score.

Why this should be rewarded

  • defines both terms accurately
  • uses the idea of named storage rather than vague description
  • explains the assignment in the correct order
  • shows understanding that the value is updated, not compared
Weak response

A variable is something that changes and a constant is something important. score ← score + 1 is wrong because the score cannot equal itself plus one.

Why this loses marks

  • the variable definition is too vague
  • the constant definition is incorrect
  • the assignment statement is interpreted as maths rather than programming
  • there is no explanation of storing a new value back into score

Practice Questions

Question 1

A programmer is creating a school quiz program. Decide whether each of these should be a variable or a constant: studentName, score, TOTAL_QUESTIONS, PASS_MARK. [4 marks]

Marking guidance

  • studentName = variable
  • score = variable
  • TOTAL_QUESTIONS = constant
  • PASS_MARK = constant

Question 2

Explain what happens in the two statements below.

total ← 10
total ← total + 5

[4 marks]

Marking guidance

  • 1 mark for stating that total is first assigned the value 10
  • 1 mark for stating that the current value of total is then used
  • 1 mark for stating that 5 is added
  • 1 mark for stating that the new value 15 is stored back in total

Question 3

A student writes: MAX_SCORE ← 100 and later writes MAX_SCORE ← 120.

Explain why this may be poor programming practice. [3 marks]

Marking guidance

  • 1 mark for recognising that MAX_SCORE looks like a constant
  • 1 mark for explaining that a constant should not change during the running of the program
  • 1 mark for explaining that changing it reduces clarity or suggests the wrong identifier was chosen

Question 4

Rewrite this idea using sensible identifiers and assignment:

  • store the user's age
  • store a fixed bus fare of 2.50
  • calculate the total cost for two tickets

[5 marks]

Marking guidance

Reward sensible pseudocode such as:

age ← user input
BUS_FARE ← 2.50
totalCost ← BUS_FARE * 2

Give credit for:

  • appropriate variable for age
  • appropriate constant for bus fare
  • meaningful identifier names
  • correct assignment statements
  • correct calculation for total cost

Question 5

A student says, “Variables only store numbers.” Explain why this is incorrect. [3 marks]

Marking guidance

  • 1 mark for saying variables can store different data types
  • 1 mark for giving at least one valid non-numeric example such as a string or Boolean
  • 1 mark for linking this to program needs or data type choice

Common Misconceptions

  • “The equals sign in code always means the same as in maths.” In programming, assignment means storing a value, not proving two sides are permanently equal.
  • “A constant is just a value that is used a lot.” A constant is a named value that should stay fixed while the program runs.
  • “Variables only store numbers.” Variables can also store text, Boolean values, dates, and other data types depending on the language.
  • “Declaration and assignment are the same thing.” Declaration introduces the identifier; assignment gives it a value.
  • “****score ← score + 1 must be wrong.” It is valid because the old value is read first, then replaced by the updated one.
  • “Good code can use any variable name as long as it works.” Meaningful identifiers matter because AQA rewards clear logic and readable solutions.

FAQ

Do students need to know declaration even if the language they use is flexible?

Yes. Even if the classroom language does not force formal declaration in the same way as others, students should still understand the concept of naming a value and using a suitable data type.

Should I still teach constants if the programming language does not enforce them strongly?

Yes. The idea still matters because it improves code clarity and helps students decide which values should remain fixed in an algorithm.

What is the best way to explain assignment quickly?

Use the phrase: work out the right-hand side, store the answer on the left-hand side. Then make students test that sentence against several examples.

How precise do student definitions need to be?

Quite precise. A vague phrase such as “a variable is something that changes” may show partial understanding, but stronger answers refer to named storage and changing values during program execution.

What do examiners usually reward on this topic?

They usually reward accurate definitions, correct tracing of assignment statements, sensible identifier choices, and explanations that show students understand how values are stored and updated.

How can I stop students mixing up assignment and comparison?

Teach them to read code in words. For example, score ← 7 becomes “store 7 in score”, while score = 7 in a condition becomes “is score equal to 7?” That verbal difference helps a lot.


Make programming answers quicker to mark

Marking programming explanations can become surprisingly slow once the class starts producing twenty different versions of “it kind of changes the variable somehow”. Marking.ai helps teachers review responses more quickly, spot recurring misconceptions, and give sharper feedback on terminology, tracing, and exam technique.

Even on short programming questions, that means less time decoding woolly answers and more time helping students become precise, confident programmers.