math modules includes two commonly used mathematical constants.
math.pi- The mathematical constant pi
math.e- The mathematical constant e (base of natural logarithm)
>>> 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