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

Knowledge organisers / Output and Sequence

Literals vs variables

All topicsPractise exam questions
Knowledge organiser

Output and Sequence

301.1b

Output both fixed text and variable values.

What you need to know

A literal is a fixed value written directly in the code (like "hello" or 42). A variable is a named container whose value can change. You can print both in the same statement.

Key points

  • A literal is a value typed directly: "hello", 42, 3.14
  • A variable stores a value that can change: name = "Alice"
  • print() can mix literals and variables using commas
  • Changing a variable does not affect previous output

Code examples

Literals vs variables
python
name = "Alice"
print("Hello", name)
print("The number is", 7)