Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Variables and Constants

Declare variables

All topicsPractise exam questions
Knowledge organiser

Variables and Constants

301.3a

Create named storage.

What you need to know

A variable is created by assigning a value with =. Python does not need a keyword like 'var' — the variable is created the moment you first assign to it.

Key points

  • Use = to assign: age = 15
  • The variable is created on first assignment
  • You can reassign: age = 16 overwrites the old value
  • Variables hold one value at a time

Code examples

Declaring variables
python
name = "Alice"
age = 15
score = 89.5
print(name, age, score)