all Python 3mathterm
math.e
constants
Euler's number e ≈ 2.718281828459045 — the base of the natural logarithm.
Syntax
math.e
This is an ordinary double — the nearest representable value to the true e, not a symbolic constant — so math.e ** x drifts from math.exp(x) in the last bits; use math.exp() when you want the exponential. Also note that math.log(x) is already the natural logarithm: passing math.e as a second argument adds a needless division and its rounding error.
Examples
import math
print(math.e) # → 2.718281828459045
print(math.e ** 2) # → 7.389...
print(math.log(math.e)) # → 1.0
print(math.exp(1)) # → 2.718...
print(math.e ** math.pi) # → 23.140...
print(round(math.e, 5)) # → 2.71828
See also
Open in the full glossarydocs.python.orgReport an inaccuracy