Python Function Reference

math.pi

The number π, the ratio of a circle’s circumference to its diameter.

Python 3.13
math.pi

Return value

The float 3.141592653589793.

Examples

The value of π

Python 3.13
import math
print(math.pi)
3.141592653589793

Area of a circle

Python 3.13
import math
radius = 2
print(round(math.pi * radius ** 2, 2))
12.57

Details

It is a constant, not a function: write it without parentheses, math.pi() raises TypeError. The value is approximate, so math.sin(math.pi) gives a very small number instead of 0. For a full turn, there is the math.tau constant equal to 2π.

See also

Where to learn