Python Glossary Русский

all Python 3cmathterm

cmath.e

constants

The number e in the cmath module: a float with the same value as math.e, the base of the natural logarithm.

Syntax

cmath.e

It is a float, although cmath.exp(1) returns the complex (2.718281828459045+0j); cmath.exp(1) == cmath.e is still True because the imaginary part is zero. For powers write cmath.exp(z) rather than cmath.e ** z, it is more accurate. The value is the same as math.e.

Examples

import cmath
print(cmath.e)  # → 2.718281828459045
print(cmath.exp(1), cmath.exp(1) == cmath.e)  # → (2.718281828459045+0j) True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy