Constants in Python

This tutorial will teach you how to define Python constants.

Variables are useful for storing values. However, these values should not be changed during the program’s execution.

You can use constants to accomplish this in different programming languages. Constants are similar to variables, except that their values do not change as the programme runs.

Constants aren’t supported in Python, which is unfortunate.

To get around this, name a variable with all capital letters to indicate it should be handled as a constant. As an illustration:


If you come across variables like this, don’t change their values. These variables are fixed by convention rather than by rules.

%d bloggers like this: