The area of a circle is π × r², where r is the radius. Python's math module has an accurate value of π.
The program
python
import math radius = float(input("Radius: ")) area = math.pi * radius ** 2 circumference = 2 * math.pi * radius print(f"Area = {area:.2f}") print(f"Circumference = {circumference:.2f}")
Typed in this example: 5. Press Run to type your own.
output
Radius: 5 Area = 78.54 Circumference = 31.42
How it works
import mathgives you access to themathmodule, which comes with Python.math.piis 3.141592653589793.radius ** 2squares the radius.**is done before*, so this is π × (r²), as the formula needs.:.2finside the f-string rounds the printed number to 2 decimal places. The variable itself keeps its full value.