This Python program receives the radius of a circle from the user and calculates the following properties:
- Diameter
- Circumference
- Area
Using the formulas:
Diameter = 2 × radius
Circumference = 2 × radius × π
Area = radius × radius × π
import math
# Read radius from user
radius = float(input("Enter the radius of the circle: "))
# Calculate properties
diameter = 2 * radius
circumference = 2 * radius * math.pi
area = radius * radius * math.pi
# Display results
print("\n--- Result ---")
print(f"Diameter: {diameter}")
print(f"Circumference: {circumference:.4f}")
print(f"Area: {area:.4f}")
Enter the radius of the circle: 7
--- Result ---
Diameter: 14.0
Circumference: 43.9823
Area: 153.9380
- The radius is read as a floating-point number
- Diameter is calculated by multiplying the radius by 2
- Circumference and area use the constant π from the math module
- Results are printed with four decimal places for clarity