Skip to main content
EnglandComputer ScienceSyllabus dot point

How does a program store and label the data it works with?

Use the common data types, declare and assign variables and constants, and understand the difference between a variable and a constant.

A focused answer to AQA GCSE Computer Science 3.2.1, covering the common data types, declaring and assigning variables and constants, and the difference between a variable and a constant.

Generated by Claude Opus 4.87 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. Common data types
  3. Variables
  4. Constants
  5. Variable versus constant
  6. Why the data type affects storage and operations
  7. Try this

What this dot point is asking

AQA wants you to know the common data types, to declare and assign values to variables and constants, and to explain the difference between a variable and a constant.

Common data types

Choosing the right type matters for two reasons. First, it controls what operations are valid: you can do arithmetic on an integer or real but not on a string of letters. Second, it affects storage and accuracy: an integer cannot hold a decimal, so storing a price of 4.99 as an integer would lose the pence. A person's age fits an integer, a price fits a real, a yes/no answer fits a Boolean, and a name fits a string.

Variables

In AQA pseudocode you write score <- 0 to store 0 in the variable score. Later score <- score + 1 reads the current value, adds 1, and stores the result back, so the value changes as the program runs. Each variable has a name (an identifier) chosen to describe what it holds.

Constants

Using a constant makes a program clearer and safer: the value is given a meaningful name, it cannot be altered by accident, and if it ever needs updating it is changed in one place rather than hunted for throughout the code.

Variable versus constant

The key difference is whether the value can change:

  • A variable can be reassigned a new value during execution.
  • A constant keeps the same value throughout, which prevents accidental changes and makes the code easier to read and maintain.

Why the data type affects storage and operations

Choosing a data type is not only about the kind of value; it also decides how much memory is used and what operations are allowed. A Boolean needs only a single bit in principle, an integer a fixed number of bytes, and a string grows with its length, so picking a smaller appropriate type saves memory across thousands of records. The type also controls valid operations: you can do arithmetic on integers and reals, comparisons on most types, and concatenation on strings, but you cannot multiply two strings of letters. This is why a number entered as text must be converted to an integer or real before it can be used in a calculation.

Try this

Q1. State the most suitable data type for storing whether a user is logged in. [1 mark]

  • Cue. Boolean, because it stores only True or False.

Q2. Explain one difference between a variable and a constant. [2 marks]

  • Cue. A variable's value can change as the program runs; a constant's value is fixed and cannot change.

Exam-style practice questions

Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

AQA 20184 marksFor each of the following, state the most suitable data type and justify your choice: a person's age, the price of an item, whether a light is on, and a person's first name.
Show worked answer →

Age: integer, because age is a whole number with no decimal part. Price: real (float), because money often has a decimal part such as 4.99. Whether a light is on: Boolean, because it has exactly two states (True or False, on or off). First name: string, because it is a sequence of characters.

Markers reward each correct type with a justification tied to the kind of value (whole versus decimal, two-state, text). Choosing integer for the price would lose marks because the decimal part would be lost.

AQA 20213 marksExplain the difference between a variable and a constant, and give one reason a programmer might use a constant for a value such as the rate of VAT.
Show worked answer →

A variable is a named store whose value can change while the program runs; a constant is a named value that is fixed and cannot change once set.

A programmer would use a constant for the VAT rate because the rate stays the same throughout the program, so making it constant prevents it being changed by accident, and giving it a meaningful name makes the code clearer and easier to update in one place if the rate ever changes.

Markers reward the can-change versus fixed distinction and a reason (safety from accidental change, clarity, single point of update).

Related dot points

Sources & how we know this