📁 Paper 1 · 3.2 Programming
3.2.2a Variables, Constants & Operators
AQA 8525 · GCSE Computer Science · ~10 min read
Notes
──
Video
──
Worksheet
──
Quiz

Variables

A variable is a named location in memory that stores a value that can change during program execution.

// Declaring and using variables score ← 0 // starts at 0 score ← score + 10 // changed to 10 name ← "Alice" // a string variable

The AQA assignment operator is (left-arrow). The right-hand side is evaluated first, then stored in the variable on the left.

Constants

A constant is a named value that cannot change once set. Constants make code more readable and easier to maintain — if a value needs updating, you only change it in one place.

CONSTANT PI ← 3.14159 CONSTANT MAX_SCORE ← 100 CONSTANT GREETING ← "Hello"
FeatureVariableConstant
Value can change?YesNo
Naming conventioncamelCase or lowercaseUPPER_CASE
Examplescore ← 0CONSTANT MAX ← 100

Arithmetic Operators

OperatorMeaningExampleResult
+Addition5 + 38
-Subtraction10 - 46
*Multiplication3 * 412
/Division (real)7 / 23.5
DIVInteger division (floor)7 DIV 23
MODRemainder (modulus)7 MOD 21
^Exponentiation (power)2 ^ 38

DIV and MOD in Practice

// Convert 150 minutes to hours and minutes hours ← 150 DIV 60 // 2 mins ← 150 MOD 60 // 30 OUTPUT hours " hours " mins " minutes"

MOD is also useful for checking if a number is even (n MOD 2 = 0) or for cycling through array indices.

Comparison Operators

OperatorMeaningExampleResult
==Equal to5 == 5True
!=Not equal to5 != 3True
<Less than3 < 7True
>Greater than7 > 3True
<=Less than or equal to5 <= 5True
>=Greater than or equal to4 >= 6False

INPUT and OUTPUT

nameINPUT("Enter your name: ") age ← int(INPUT("Enter your age: ")) OUTPUT "Hello " + name OUTPUT "You are " + str(age) + " years old"
Exam tip: AQA always uses ← for assignment (never =). DIV and MOD are AQA keywords — always capitalise them. Many marks are lost by writing % for MOD.
⚠️ Common Mistakes
  • Using = instead of ← for assignment in pseudo-code
  • Writing % for modulus — AQA always uses MOD
  • Forgetting that / gives a real result while DIV gives an integer
  • Using the same name for a constant and a variable
Video coming soon

Key points

  • Difference between variables and constants
  • The ← assignment operator in AQA pseudo-code
  • DIV vs / and MOD with worked examples
  • How INPUT and OUTPUT work in AQA
Click slide or press arrow keys to navigate
✍️

Worksheet — 3.2.2a

8 questions · 21 marks · Mark schemes on submit

Q1What is the difference between a variable and a constant? Give one example of each.[3]
✅ Mark scheme
Mark scheme
Variable: value can change during execution [1]; Constant: value is set once and cannot change [1]; One example of each e.g. score ← 0 / CONSTANT MAX ← 100 [1].
Q2Calculate: (a) 17 DIV 5 (b) 17 MOD 5 (c) 2 ^ 4 (d) 13 MOD 4[4]
✅ Mark scheme
Mark scheme
(a) 3 [1]; (b) 2 [1]; (c) 16 [1]; (d) 1 [1].
Q3Write AQA pseudo-code to convert 500 seconds into minutes and seconds and output both values.[3]
✅ Mark scheme
Mark scheme
minutes ← 500 DIV 60 [1]; seconds ← 500 MOD 60 [1]; OUTPUT minutes and seconds [1].
Q4What does this code output? x ← 10, y ← 3, OUTPUT x DIV y, OUTPUT x MOD y[2]
✅ Mark scheme
Mark scheme
3 [1]; 1 [1].
Q5State the AQA assignment operator and explain why it differs from the equals sign (=).[2]
✅ Mark scheme
Mark scheme
← (left arrow) [1]; = means equality (comparison) whereas ← means "assign this value to the variable" [1].
Q6How can you check if a number n is even using MOD? Write the condition.[2]
✅ Mark scheme
Mark scheme
n MOD 2 == 0 [1]; if this is True, n is even [1].
Q7Write pseudo-code to ask the user for two numbers and output their sum, difference, and product.[3]
✅ Mark scheme
Mark scheme
a ← int(INPUT()); b ← int(INPUT()) [1]; OUTPUT a+b [1]; OUTPUT a-b, a*b [1].
Q8State two reasons why using constants is better than writing the value directly in code (magic numbers).[2]
✅ Mark scheme
Mark scheme
Any 2: makes code more readable/self-documenting [1]; easier to change — only one place to update [1]; prevents accidental change to the value [1].
Check your answers against the mark schemes.
Topic Quiz
Q 1 of 10
You scored
out of 10
Card 1 of 6
Click to flip
🎉
All done!
TermDefinition
🎯

Mini Test — 3.2.2a

Timed exam conditions.

  • 8 questions · 10 minutes
  • 5 MCQ + 3 short answer
← 3.2.1 Data Types
10 of 57 · AQA 8525
3.2.2b Selection →