Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
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, for example score = 0, lives = 3, price = 0.0.
  • A constant stores a fixed value that does NOT change during execution, for example const VAT = 0.2 or const MAX_LIVES = 3.
  • Assignment uses = to store a value in a variable, for example username = "player1". Do NOT use == for assignment.
  • Input receives data from the user, for example name = input("Enter your name"). Note: input cannot be used as a variable name.
  • Output displays data or information to the user, for example 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: if name holds "player1", print("Hello", name) outputs Hello player1.

Code examples

Variables, constants, input and output (OCR Exam Reference Language)
text
// Constant (does not change)
const VAT_RATE = 0.2

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

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

// Output
print("Total with VAT: " + str(total))
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)

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

  • Mistake:Writing assignment backwards, or thinking a variable keeps its old value. The variable ALWAYS goes on the left (name = input("Name?"), never input("Name?") = name), and a new value REPLACES the old one: after lives = 3 then lives = 5, lives holds 5 only.
  • Mistake:Putting a variable's NAME in quotes. print("lives") outputs the word lives, not its value. Keep text inside the quotes and variables outside them, joined with +: print("Lives left: " + str(lives)).
  • Tip:When asked to identify a constant, look for a value that stays the same for the whole program, for example a tax rate or the maximum number of lives in a game. A constant doesn't need to change during runtime, and updating it once updates it everywhere it is used.
  • Tip:When asked to identify variables, look for named values that change, for example score, total or lives. Give the exact identifier from the code.
  • Tip:Variable names MUST NOT contain spaces. Letters, digits and underscores are allowed, but a name can't start with a digit: firstName, score2 and top_score are valid; first name and 2score are not. Use the exact name the question gives; a version with a space is not accepted.
  • Mistake:Forgetting to cast. age = input("Age? ") followed by age + 1 causes an error, because age is a string, not a number.

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

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

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