What are constants in Python?
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
- Python is an easy language to use and understand.
- There are no complicated steps in Python.
Constants: Variables that hold a value and cannot be changed are called constants.
- Constants are rarely used in Python – this helps to hold a value for the whole program.
- Constants are usually declared and assigned for different modules or assignments.
#initialization of constantsPI = 3.14LAMBDA = 0.01
We initialize constants in capital letters as it helps us to write more semantic than static code.
main.py
constant.py
import constantprint(constant.PI)print(constant.LAMBDA)