Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

math.pi

Supplies the floating-point constant used for half a turn in radians.

Version: Python 3.14; repository image, production runtime not attested

Syntax

math.pi

Supplies the floating-point constant used for half a turn in radians.

Circle calculations inherit floating-point rounding; round the displayed result after computing.

Pi relates circumference to diameter. A circle of radius 3 has diameter 6, so its circumference is 6π, displayed as 18.85. A half turn measures π radians or 180 degrees. The constant is a finite-precision float, so rounding is best applied to the final display.

import math
assert round(2 * math.pi * 3, 3) == 18.85
assert math.degrees(math.pi) == 180.0

Examples

import math
print(round(2 * math.pi * 3, 3))
print(round(math.degrees(math.pi), 1))

Result

18.85
180.0

Pi relates circumference to diameter. A circle of radius 3 has diameter 6, so its circumference is 6π, displayed as 18.85. A half turn measures π radians or 180 degrees. The constant is a finite-precision float, so rounding is best applied to the final display.

Sources