Python Constant
Table of Content:
- What is constant?
- Declaring and assigning value to a constant.
- Don't changing the value of a constant.
- How to utilize module.
Assigning value to constant in Python
In Python, constants are usually declared and assigned in a module. Here, the module is a new file containing variables, functions, etc which is imported to the main file. Inside the module, constants are written in all capital letters and underscores separating the words.
Declaring and assigning value to a constant
constant.py
PI = 3.14 INTREST = 2.8 LAMDA = 0.01
main.py
import constant print(constant.PI) print(constant.INTREST) print(constant.LAMDA)