← IGCSE Computer Science Paper 2

Meaningful identifiers for variables and constants

A name that describes what a variable or constant holds, such as TotalToPay instead of T, so the program is easy to read and maintain.

Understanding Meaningful identifiers for variables and constants in IGCSE Computer Science Paper 2

What it does: Using i for an index is a widely understood convention, so a single letter is fine here. X and Y are standard names for coordinates, so they are meaningful in that context. TotalToPay describes what the variable holds, so the program is easier to read. A single letter like T tells you nothing. The computer does not care about the name. Meaningful names help people read, understand and update the code. The first line shows what each value means. The second line forces the reader to guess. Single letters are only fine where they are conventional, such as i and j for indexes or X and Y for coordinates. A bill total needs a descriptive name.

Common mistakes: X says nothing about what it holds. The variable declared to hold the final amount is TotalToPay, so the line should be TotalToPay ← HourlyRate * 8. A single letter X does not tell the reader this is the pay per hour. It should be HourlyRate ← 12.5, which also matches its use on line 3.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 347–357) and word search (Modules 337–357).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which identifier is better for a variable that stores the total cost of a customer's shopping?
TotalToPayT
Matches
T ← Price * Quantity
↓
T is a poor identifier because it does not say what it holds. Rename it to something like TotalToPay so the purpose is clear.
Applying
Meanings
Term
meaningful identifier
Meaning
A name that describes what a variable or constant holds, such as TotalToPay instead of T, so the program is easy to read and maintain.
Practice
DECLARE HoursWorked : INTEGER
Testing
Gaps
TotalToPay ← Price + Price *
Check Answer
Spots
3HourlyRate ← 12.5
4X ← HourlyRate * 8

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Squirrel' badge — Module Hoarder, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which identifier is better for a variable that stores the total cost of a customer's shopping?
A. TotalToPay ✓
B. T
TotalToPay describes what the variable holds, so the program is easier to read. A single letter like T tells you nothing.
2. Which identifier is better for a variable that stores how much an employee earns per hour?
A. HourlyRate ✓
B. X
HourlyRate describes the value stored. X gives no clue about what the variable is for.
3. Why should a programmer choose meaningful identifiers?
A. They make the program run faster
B. They make the program easier to read and maintain ✓
The computer does not care about the name. Meaningful names help people read, understand and update the code.
4. Which line is easier to understand?
A. T ← P * Q
B. TotalToPay ← Price * Quantity ✓
The first line shows what each value means. The second line forces the reader to guess.
5. When is a single-letter identifier acceptable?
A. As an index in a loop, such as i or j ✓
B. For a value such as a customer's total bill
Single letters are only fine where they are conventional, such as i and j for indexes or X and Y for coordinates. A bill total needs a descriptive name.

Match the Pairs

DECLARE TotalToPay : REAL → A meaningful identifier: the name tells the reader the variable holds the total amount a customer has to pay
CONSTANT HourlyRate ← 12.50 → A meaningful constant name that says the fixed value is the pay for each hour worked
A single letter name is acceptable when it is conventional, such as i as an index counting through an array → FOR i ← 1 TO 10
Single letters are also conventional for coordinates, such as X and Y for a position on a grid → X ← X + 1
T ← Price * Quantity → T is a poor identifier because it does not say what it holds. Rename it to something like TotalToPay so the purpose is clear.
X ← Hours * Rate → X is used for a pay amount, but X normally means a coordinate. Rename it to something like TotalPay to show what it holds.

Key Term

meaningful identifier
A name that describes what a variable or constant holds, such as TotalToPay instead of T, so the program is easy to read and maintain.

Fill in the Blanks

1. CONSTANT VatRate ← 0.2 Price ← 50 TotalToPay ← Price + Price * VatRate
Hint: Type the constant whose name says it holds the tax percentage.
2. HourlyRate ← 15 HoursWorked ← 40 TotalToPay ← HourlyRate * HoursWorked
Hint: Type a meaningful variable name that describes the amount of money to be paid.
3. X ← 4 // horizontal position Y ← 7 // vertical position OUTPUT X, Y
Hint: Type the conventional single-letter name for the vertical coordinate.
4. Hours ← 8 HourlyRate ← 12.5 Pay ← Hours * HourlyRate
Hint: Type a descriptive name for the pay per hour, replacing a poor single-letter name.
5. CONSTANT PassMark ← 50 INPUT Mark IF Mark >= PassMark THEN
Hint: Type the constant's identifier that was declared on the first line, instead of a bare number.

Spot the Error

Question 1
A DECLARE HourlyRate : REAL
B DECLARE TotalToPay : REAL
C HourlyRate ← 12.5
D X ← HourlyRate * 8
Line D — X says nothing about what it holds. The variable declared to hold the final amount is TotalToPay, so the line should be TotalToPay ← HourlyRate * 8.
Question 2
A X ← 12.5
B Hours ← 8
C Wage ← HourlyRate * Hours
D OUTPUT Wage
Line A — A single letter X does not tell the reader this is the pay per hour. It should be HourlyRate ← 12.5, which also matches its use on line 3.
Question 3
A T ← 0
B TotalToPay ← TotalToPay + 4.5
C OUTPUT TotalToPay
Line A — T is a poor name because it does not describe the value. The variable should be TotalToPay so that every line of the program refers to the same meaningful identifier.
Question 4
A DECLARE Name : STRING
B INPUT Name
C X ← LENGTH(Name)
D OUTPUT NameLength
Line C — X does not describe the number of characters it stores. A meaningful name such as NameLength should be used: NameLength ← LENGTH(Name).
Question 5
A CONSTANT VatRate ← 0.2
B INPUT Price
C A ← Price * VatRate
D OUTPUT VatAmount
Line C — The single letter A hides that this value is the VAT charged. It should be VatAmount ← Price * VatRate so the program is easy to read.

Student with a class code? Join your class →