Constants

suggest change

math modules includes two commonly used mathematical constants.

>>> from math import pi, e
>>> pi
3.141592653589793
>>> e
2.718281828459045
>>>

Python 3.5 and higher have constants for infinity and NaN (“not a number”). The older syntax of passing a string to float() still works.

math.inf == float('inf')
# Out: True

-math.inf == float('-inf')
# Out: True

# NaN never compares equal to anything, even itself
math.nan == float('nan')
# Out: False

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents