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.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
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
- Use the three programming constructs of sequence, selection and iteration, including definite and indefinite iteration, and nest them.
A focused answer to AQA GCSE Computer Science 3.2.2, covering the three programming constructs of sequence, selection and iteration, the difference between definite and indefinite iteration, and nesting.
- Use arithmetic operators including integer division and modulus, comparison operators, and the Boolean operators AND, OR and NOT, applying correct operator precedence.
A focused answer to AQA GCSE Computer Science 3.2.3 and 3.2.4, covering arithmetic operators including integer division and modulus, comparison operators, and the Boolean operators AND, OR and NOT with operator precedence.
- Use one-dimensional and two-dimensional arrays and records to store collections of data, and access elements using indexes and field names.
A focused answer to AQA GCSE Computer Science 3.2.6, covering one-dimensional and two-dimensional arrays and records, and accessing elements using indexes and field names.
- Apply the principles of structured programming, breaking a problem into subroutines with clear interfaces, and explain the benefits of this approach.
A focused answer to AQA GCSE Computer Science 3.2.11, covering the principles of structured programming, breaking a problem into subroutines with clear interfaces, and the benefits of the approach.
Sources & how we know this
- AQA GCSE Computer Science (8525) specification — AQA (2020)