+ 1

How do I declare and unchangeable variable in python?

11th May 2021, 6:19 AM
Chinonso Ozumba 🇳🇬
Chinonso Ozumba 🇳🇬 - avatar
2 Answers
+ 3
I support the statement declared by Thirt13n. Instead, you can create a different file of all constants and import it into your code. Like, make a file constants.py which has code as follows :- PI = 3.141.. A = 10 Now,import this constants.py to any of your codes where you wanna use those constants. Ex:- import constants print(constants.PI) #3.141.. print(constants.A) #10 Hope you got it!!
11th May 2021, 6:49 AM
sarada lakshmi
sarada lakshmi - avatar
+ 2
Hey Chinonso Ozumba 🇳🇬 You can't declare a variable or value as constant in Python. Just don't change it.
11th May 2021, 6:26 AM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar