You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers the fundamental building blocks of every program — variables, constants, and data types. Understanding these concepts is essential for GCSE Computer Science (AQA 3.2 / OCR J277 2.2) and forms the foundation of all programming topics.
A variable is a named location in memory that stores a value which can change during the execution of a program. Think of it as a labelled box — the label is the variable name, and the contents of the box is the value.
In pseudocode (AQA style):
name ← "Alice"
age ← 16
score ← 0
In Python:
name = "Alice"
age = 16
score = 0
The assignment operator (← in pseudocode, = in Python) stores the value on the right into the variable on the left. Variables can be reassigned at any time:
score = 10
score = score + 5 # score is now 15
totalScore not x).totalScore) or snake_case (total_score).if, while, print.Exam Tip: The examiner wants you to use meaningful identifiers. A variable called
twill often lose you marks compared withtemperature.
A constant is a named value that is set once and cannot be changed during the execution of the program. Constants make code easier to read and maintain.
In pseudocode:
CONST VAT_RATE ← 0.20
CONST PI ← 3.14159
In Python (by convention — Python does not enforce constants):
VAT_RATE = 0.20
PI = 3.14159
| Benefit | Explanation |
|---|---|
| Readability | VAT_RATE is clearer than 0.20 scattered through code |
| Maintainability | Change the value in one place and it updates everywhere |
| Error prevention | Prevents accidental modification of important values |
Exam Tip: If a question asks the difference between a variable and a constant, state that a variable's value can change during execution whereas a constant's value is fixed once assigned.
A data type defines the kind of value a variable can hold. The five data types you must know for GCSE are:
| Data Type | Description | Example |
|---|---|---|
| Integer | A whole number (positive or negative) | 42, -7, 0 |
| Real / Float | A number with a decimal point | 3.14, -0.5, 100.0 |
| Boolean | A value that is either True or False | True, False |
| Character | A single letter, digit, or symbol | 'A', '7', '!' |
| String | A sequence of characters | "Hello", "GCSE2025" |
An integer has no fractional part: 5, -12, 0. A real (also called a float) has a decimal point: 5.0, -12.75. This distinction matters because integers use less memory and arithmetic with them is faster.
A Boolean can only hold one of two values: True or False. Booleans are central to selection and iteration because conditions evaluate to a Boolean result.
is_logged_in = True
has_passed = score >= 50 # evaluates to True or False
A character (char) is a single symbol, whereas a string is zero or more characters in sequence. In Python, there is no separate char type — a single character is simply a string of length 1.
letter = 'A' # character (string of length 1 in Python)
greeting = "Hello" # string of length 5
Sometimes you need to convert between data types. This is called casting.
age = int("16") # string → integer
price = float("9.99") # string → real
label = str(42) # integer → string
In pseudocode:
age ← INT("16")
price ← REAL("9.99")
label ← STRING(42)
Casting is essential when reading user input, because input() in Python always returns a string:
age = int(input("Enter your age: "))
Exam Tip: A very common error in exam pseudocode answers is forgetting to cast the input to an integer before comparing it with a number. Always show the cast explicitly.