Answers for "python constant"

5

delcare consatnt python

# You can't, just use uppercase to identify
Posted by: Guest on October-31-2020
18

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.
Posted by: Guest on January-27-2021
4

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'
Posted by: Guest on May-13-2021
-1

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.
Posted by: Guest on July-30-2021

Python Answers by Framework

Browse Popular Code Answers by Language