Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Programming Fundamentals

Variables, constants, operators, inputs, outputs and assignments

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

2.2.1 Programming Fundamentals

Practise exam questions

Programming Fundamentals — Note 1 of 6

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.

What to know

  • 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.
  • input() ALWAYS returns a string. Wrap it in int() or float() before doing any maths with the value.
  • print() with commas puts a space between each item: print("Hello", name) outputs Hello Sam.

Key terms

Variable Declaration

The act of creating a named location in memory to store a value. The value can change during program execution.

Constant Declaration

The act of creating a named memory location whose value cannot change during program execution.

Exam technique

  • 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.
  • Tip:When asked to identify variables, look for named values that change: radius, area, score, staffID, etc. Give the exact identifier from the code.
  • Tip:Variable names MUST NOT contain spaces. Penalised if you write 'word 1' instead of word1.
  • Mistake:Forgetting to cast. age = input("Age? ") followed by age + 1 causes an error, because age is a string, not a number.

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)
Input and output in Python
python
name = input("Enter your name: ")
print("Hello", name)

# input() returns a string, so cast it before doing maths
age = int(input("Enter your age: "))              # whole number
height = float(input("Enter your height in m: "))  # decimal

print("Next year you will be", age + 1)

Ready to test yourself?

Practise 2.2.1 questions
← Previous topicInsertion sort2.1.3 Searching and sorting algorithmsNext note →Sequence2.2.1 Programming Fundamentals

Back to Programming Fundamentals

Revise another OCR GCSE topic: Data Types, Additional Programming Techniques

Programming Fundamentals

Note 1 of 6

  1. 1Variables, constants, operators, inputs, outputs and assignments
  2. 2Sequence
  3. 3Selection
  4. 4Iteration (count- and condition-controlled loops)
  5. 5Arithmetic operators
  6. 6Boolean operators AND, OR and NOT
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).