Mathematical Programs · Python example
Import the math module and use pi to calculate circle measurements.
Python's math module provides mathematical constants and functions. Here math.pi supplies an accurate value of π.
import math
radius = 4.5
area = math.pi * radius ** 2
circumference = 2 * math.pi * radius
print(f"Area: {area:.2f}")
print(f"Circumference: {circumference:.2f}")