Part of the series

Several example codes

~1 min read • Updated Sep 30, 2025

Program Overview

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 × π


Python Code:


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}")

Sample Output:


Enter the radius of the circle: 7  

--- Result ---  
Diameter: 14.0  
Circumference: 43.9823  
Area: 153.9380

Explanation:

- 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


Written & researched by Dr. Shahin Siami