Knowledge Organiser: Variables and Constants
Part of Variables & Constants · GCSE GCSE Computer Science revision
This topic summary covers Knowledge Organiser: Variables and Constants within Variables & Constants for GCSE Computer Science. Revise Variables & Constants in Programming for GCSE Computer Science with 15 exam-style questions and 10 flashcards. This topic appears less often, but it can still be a useful differentiator on mixed-topic papers. It is section 7 of 7 in this topic. Use this topic summary to connect the idea to the wider topic before moving on to questions and flashcards.
Topic position
Section 7 of 7
Practice
15 questions
Recall
10 flashcards
Knowledge Organiser: Variables and Constants
Key Terms
- Variable: A named memory location that stores a value which can change during the program
- Constant: A named value that is set once and cannot be changed during the program
- Assignment: Giving a value to a variable using = (e.g.
score = 10) - Naming convention: Rules for how variable names should be formatted (camelCase, UPPER_CASE)
- Reserved word: A keyword the language uses (if, while, for) — cannot be used as a variable name
Must-Know Facts
- Variables can be reassigned; constants cannot change after being set
- Variable names are case sensitive:
Scoreandscoreare different - Names must start with a letter or underscore, not a number
- No spaces in variable names — use camelCase or snake_case instead
- Constants are often written in UPPER_CASE by convention (e.g.
VAT_RATE) - Constants prevent accidental changes and make code easier to update
Key Concepts
- Use variables for: scores, counters, user input — anything that changes
- Use constants for: PI, tax rates, fixed limits — things that never change
- Declare constant:
const PI = 3.14159 - Good name example:
playerScore(meaningful) notx(meaningless)
Common Mistakes
- Using meaningless variable names: Names like
x,temp, oraare not acceptable in exam pseudocode — use meaningful names likeplayerScoreortotalCost - Trying to change a constant's value: Constants cannot be reassigned after being set — attempting to do so is a logic/runtime error and defeats the purpose of using a constant
- Starting a variable name with a number: Variable names must begin with a letter or underscore —
1scoreis invalid;score1is valid - Putting spaces in variable names: Spaces are not allowed — use camelCase (
playerScore) or underscores (player_score) instead of spaces - Using a reserved word as a variable name: Words like
if,while,for, andprintare reserved by the language and cannot be used as variable names
Revise this topic interactively on PrepWise — self-test mode, tap-to-reveal definitions, and Common Mistakes from examiners.
Try the interactive Knowledge Organiser — free →