What is a Data Type?
A data type defines the kind of value a variable can store and the operations that can be performed on it. Choosing the correct data type makes programs more efficient and reduces errors.
The Core Data Types in AQA
| Data Type | Description | Example | AQA Keyword |
| Integer | Whole number (positive, negative, or zero) | 42, -7, 0 | int |
| Real / Float | Number with a decimal point | 3.14, -0.5, 100.0 | float/real |
| Boolean | True or False only | True, False | bool |
| Character | A single character | 'A', '3', '!' | char |
| String | A sequence of characters | "Hello", "abc123" | str/string |
Examples in AQA Pseudo-code
age ← 16 // integer
pi ← 3.14159 // real/float
passed ← True // boolean
grade ← 'A' // character
name ← "Alice" // string
Casting (Type Conversion)
Casting converts a value from one data type to another. This is needed when you want to do arithmetic on input (which arrives as a string) or display numbers as text.
| Function | Converts to | Example | Result |
| int(x) | Integer | int("42") | 42 |
| float(x) | Real | float("3.14") | 3.14 |
| str(x) | String | str(99) | "99" |
| bool(x) | Boolean | bool(0) | False |
userInput ← INPUT() // always a string
num ← int(userInput) // cast to integer before arithmetic
result ← num * 2
OUTPUT str(result) + " is the answer" // cast back to string for OUTPUT
Why Does the Data Type Matter?
- Integer vs Real: 7 / 2 = 3 (integer division loses remainder); 7.0 / 2 = 3.5 (real keeps decimal)
- String arithmetic: "3" + "4" = "34" (concatenation), not 7
- Boolean: used in conditions — IF passed = True THEN ...
Exam tip: INPUT() always returns a string. You must cast it to int() or float() before using it in arithmetic. This is a very common exam question — "why would this code cause an error?"
⚠️ Common Mistakes
- Using "float" and "real" — AQA uses both; they mean the same thing
- Forgetting to cast INPUT — age ← INPUT() then age + 1 will fail
- Confusing character (single char 'A') with string ("A" — also single but it's a string)
- Using int() to round a float — int(3.9) = 3, not 4 (it truncates, not rounds)