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

Knowledge organisers / Variables and Constants

Constants

All topicsPractise exam questions
Knowledge organiser

Variables and Constants

301.3b

Values that do not change.

What you need to know

A constant is a value that should not change while the program runs. Python has no built-in constant keyword, so by convention we use UPPER_CASE names to signal that a value should not be modified.

Key points

  • Constants are values that stay the same: VAT_RATE = 0.2
  • Use ALL_CAPS naming by convention
  • Python does not enforce constants — it's a convention
  • Constants make code easier to update and understand

Code examples

Constants convention
python
VAT_RATE = 0.2
MAX_LIVES = 3

price = 50
total = price + (price * VAT_RATE)
print(total)  # 60.0