delcare consatnt python
# You can't, just use uppercase to identify
delcare consatnt python
# You can't, just use uppercase to identify
how to define a constant in python
You can't define a constant in Python unlike in other language, hence you can
just make the variable all CAPS and add a comment using '#' saying that this is
a constant variable.
python constant
class CONST(object):
__slots__ = ()
FOO = 1234
CONST = CONST()
print(CONST.FOO) # 1234
CONST.FOO = 4321 # AttributeError: 'CONST' object attribute 'FOO' is read-only
CONST.BAR = 5678 # AttributeError: 'CONST' object has no attribute 'BAR'
python e constant
The constant e can be used when you
import math
.
The e refers to euler''s (oiler''s) constant. It is approximately 2.71828.
print(math.e)
#2.718281828459045
It is very useful when you want to make logarithms, as LOG10E has some good uses.
math.e is fixed, and thus does not change.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us