Variables & Constants

Computer ScienceOCRGCSEUnit: 3.2 Programming
Free taster
5 of 6 sections open
The basics

The Storage Boxes

The 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.

Now try it yourself

Quiz · Question 1 of 17

Which of the following best describes a variable in a program?

Tap an answer to check it

Revise every Computer Science topic, free during alpha

Variables & Constants is one of 60 topics on PrepWise — all aligned to your exam board.

Start revising free →