Definition

A named location in memory that’s value can change while the program is running.

Characteristics

  • Has an identifier
  • Value can be updated using the = assignment operator
  • declared: an identifier is given and memory reserved
  • Initialised: given an initial value at the point of declaration or later
  • Depending on the programming language, its data type may be changeable

Examples

  • name = "John"
  • age = 16
  • name = input("What is your name?")
  • length = len(names)

Non-examples

  • Constants (e.g., const x = 5, AGE = 5)

OCR J277

OCR H446