Challenge: Circle Calculator
Completed
Read the radius of a circle and use the math module to print its area (π × r²) and circumference (2 × π × r), each with 2 decimal places.
Input
One number: the radius.
Output
Area: <area> Circumference: <circumference>
Example
Input
1
Output
Area: 3.14 Circumference: 6.28
Editor
Python
Hints
import math, then use math.pi.
r ** 2 is r squared.
f"{value:.2f}" gives 2 decimal places.
Solution explanation
math.pi is much more accurate than typing 3.14 yourself.
Show solution
import math
r = float(input())
print(f"Area: {math.pi * r ** 2:.2f}")
print(f"Circumference: {2 * math.pi * r:.2f}")