Python does not have built-in constant types like some other languages. However, by convention, constants are defined using all uppercase letters, and they should not be changed once defined.
PI = 3.14159 MAX_USERS = 100 APP_NAME = "Technorank"
These values should not be modified in your program.
You can store constants in a separate file (e.g., constants.py
) and import them:
# constants.py API_KEY = "123ABC" TIMEOUT = 30 # main.py import constants print(constants.API_KEY)
Python allows you to reassign a constant (but it's discouraged):
PI = 3.14 PI = 4 # β Not recommended!
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!