Test yourself on Variables & Constants with exam style questions, marked instantly.
Flashcards that come back just before you would forget them.
A revision plan that remembers what you know and shows what to do next.
See which topics you have nailed and which need another look.
Quiz yourself on Variables & ConstantsGet your flashcardsBuild my revision planTrack my progressVideo Lesson
Craig'n'Dave: Variables and ConstantsThe Storage Boxes
Think of computer memory as a warehouse full of boxes. A variable is a labelled box where you can store data - and change what's inside whenever you want. The label (name) stays the same, but contents can change: "score = 10" then later "score = 15". A constant is a sealed box - once you put something in, it can never change. Use constants for things like PI = 3.14159 or VAT_RATE = 0.20.
The variable score changes from 0 to 10 to 25. The padlock marks constants, which are set once and never change. In OCR pseudocode a variable is written score = score + 10 and a constant is written const VAT_RATE = 0.2. Edexcel does not set a strict pseudocode style.
Variables vs Constants
| Aspect | Variable | Constant |
|---|---|---|
| Value can change? | Yes - can be reassigned | No - fixed once declared |
| Use for | Scores, counters, user input | PI, VAT rate, fixed values |
| Naming convention | camelCase or snake_case | UPPER_CASE (often) |
| Example | score = 100 | const PI = 3.14159 (OCR style) |
Deep Dive: Naming Rules
Good variable names:
- Meaningful:
playerScorenotx - Start with letter or underscore, not number
- No spaces - use camelCase or snake_case
- No reserved words (if, while, for, etc.)
- Case sensitive:
Score≠score
Why use constants?
- Prevents accidental changes
- Makes code more readable
- Easy to update in one place
Memory Trick
Variable = Varies - can change
Constant = Constant - stays the same (like a constant friend!)
Exam Tips
- When to use each: Variable for things that change, constant for fixed values
- Common mistake: Using a variable when a constant is more appropriate
Make this stick
Signing in gives access to all PrepWise features.