banner

© 2004-19 ict4u.net

Python Constants

A constant is a named data item that does no change throughout the life of a program.
It could be the value of Pi for example

Python does not require any type of data to be declared before it is used, so for the Python interpreter a constant is no different to a variable

Constant Naming Rules
  • The rules for naming a variable apply except for casing
  • Python convention is that only UPPERCASE characters are used to name a constant
    eg FIRST_DAY = "Monday"
  • Initialise the constant at the beginning of the code