Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
community creator

What are constants in Python?

Sai Pavan

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 constants
PI = 3.14 
LAMBDA = 0.01 

We initialize constants in capital letters as it helps us to write more semantic than static code.

main.py
constant.py
import constant

print(constant.PI)
print(constant.LAMBDA)

RELATED TAGS

python
community creator
RELATED COURSES

View all Courses

Keep Exploring