Mathematical Constants



e

The mathematical constant e is called as Euler's Number.

Syntax

math.e

Return Value

The math.e constant equals Euler's Number.

Example

from math import e

print ("Euler's Number: ",e)

It will produce the following output

Euler's Number: 2.718281828459045

pi

In mathematics, pi (denoted as Π ) is a mathematical constant, equal to the ratio of circumference of a circle to its diameter.

Syntax

math.pi

Return Value

The math.pi constant returns circumference/diameter.

Example

from math import pi

print ("Mathematical constant Π: ",pi)

It will produce the following output

Mathematical constant Π: 3.141592653589793

tau

In Mathematics, Tau (denoted by τ ) is defined as a mathematical constant equivalent to the ratio of circumference to radius, and is equal to 2Π.

Syntax

math.tau

Return Value

The math.tau returns circumference/radius.

Example

from math import tau

print ("Mathematical constant τ : ",tau)

It will produce the following output

Mathematical constant τ : 6.283185307179586

inf

This mathematical constant is equivalent to positive infinity. For negative infinity use - math.inf. This equivalent to float("Inf").

Syntax

math.inf

Return Value

The constant returns the positive infinity.

Example

from math import inf

print ("Positive infinity: ",inf, "is equal to", float("Inf"))
print ("Negative infinity: ",-inf, "is equal to", float("-Inf"))

It will produce the following output

Positive infinity: inf is equal to inf
Negative infinity: -inf is equal to -inf

nan

This constant is a floating-point "not a number" (NaN) value. Equivalent to the output of float('nan').

Syntax

math.nan

Return Value

This constant returns NaN standing for not a number.

Example

from math import nan

print ("Not a number:", nan, "is equal to", float("nan"))

It will produce the following output

Not a number: nan is equal to nan
python_maths.htm
Advertisements