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

Knowledge organisers / Programming Fundamentals

The use of variables, constants, operators, inputs, outputs and assignments

All topicsPractise exam questions
Knowledge organiser

Programming Fundamentals

2.2.1a

Practical use of the techniques

What you need to know

Variables and constants are fundamental building blocks of any program. A variable is a named storage location whose value can change during the program. A constant is a named value that does not change. Programs use inputs to receive data, outputs to display results, and assignment statements to store values in variables.

Key points

  • Definition:Variable Declaration: the act of creating a named location in memory to store a value. The value can change during program execution.
  • Definition:Constant Declaration: the act of creating a named memory location whose value cannot change during program execution.
  • A variable stores data that can change while the program runs, e.g. score = 0, radius = 0, area = 0.0.
  • A constant stores a fixed value that does NOT change during execution, e.g. PI = 3.142 or const VAT = 0.2.
  • Assignment uses = to store a value in a variable, e.g. name = "Alice". Do NOT use == for assignment.
  • Input receives data from the user, e.g. name = input("Enter your name"). Note: input cannot be used as a variable name.
  • Output displays data or information to the user, e.g. print("Hello World").
  • Operators perform calculations or comparisons on data (arithmetic, comparison, Boolean).
  • Constants are often written in UPPERCASE to distinguish them from variables.
  • Exam Tip:When asked to identify a constant, look for fixed values like 3.142 (pi) or boundary limits (1, 30). A constant doesn't need to change during runtime and updating it once updates it everywhere.
  • Exam Tip:When asked to identify variables, look for named values that change: radius, area, score, staffID, etc. Give the exact identifier from the code.
  • Exam Tip:Variable names MUST NOT contain spaces. Penalised if you write 'word 1' instead of word1.

Code examples

Variables, constants, input and output
python
# Constant (does not change)
VAT_RATE = 0.2

# Input
price = float(input("Enter the price: "))

# Assignment and calculation
total = price + (price * VAT_RATE)

# Output
print("Total with VAT:", total)