Python math.pi Constant

Python math 模块Python math Module

Python math.piReturns a floating point value π, generally referring to pi, the circumference ratio PI (3.1415...).

PI: 3.141592653589793。

Syntax

The syntax of the math.pi constant is as follows:

math.pi

Return Value

Returns a float 3.141592653589793, representing pi.

Example

The following example returns PI:

Example

# Import the math package
import math

# Output PI
print (math.pi)

Output result:

3.141592653589793

Python math 模块Python math Module

Other Extensions