In this python post, we would love to share with you how to find diameter circumference and area Of a circle.
The mathematical formulas are:
- Diameter of a Circle = 2r = 2 * radius
- Area of a circle is: A = πr² = π * radius * radius
- Circumference of a Circle = 2πr = 2 * π * radius
Python Program to Find Area and Circumference of Circle
Let’s follow the following algorithm to write a program to calculate the circumference of a circle in python:
- Python Program to find Diameter Circumference and Area Of a Circle
- Python Program to Calculate Diameter Circumference and Area Of a Circle
Python Program to find Diameter Circumference and Area Of a Circle
- Allow users to input the radius of a circle.
- Using the radius value, this Python formula to calculate the Circumference, Diameter, and Area Of a Circle, Diameter of a Circle = 2r = 2 * radius, Area of a circle are: A = πr² = π * radius * radius and Circumference of a Circle = 2πr = 2 * π * radius.
- Print result.
# Python Program to find Diameter, Circumference, and Area Of a Circle
PI = 3.14
radius = float(input(' Please Enter the radius of a circle: '))
diameter = 2 * radius
circumference = 2 * PI * radius
area = PI * radius * radius
print(" \nDiameter Of a Circle = %.2f" %diameter)
print(" Circumference Of a Circle = %.2f" %circumference)
print(" Area Of a Circle = %.2f" %area)
After executing the python program, the output will be:
Please Enter the radius of a circle: 5 Diameter Of a Circle = 10.00 Circumference Of a Circle = 31.40 Area Of a Circle = 78.50
Python Program to Calculate Diameter Circumference and Area Of a Circle
# Python Program to find Diameter, Circumference, and Area Of a Circle
import math
def find_Diameter(radius):
return 2 * radius
def find_Circumference(radius):
return 2 * math.pi * radius
def find_Area(radius):
return math.pi * radius * radius
r = float(input(' Please Enter the radius of a circle: '))
diameter = find_Diameter(r)
circumference = find_Circumference(r)
area = find_Area(r)
print("\n Diameter Of a Circle = %.2f" %diameter)
print(" Circumference Of a Circle = %.2f" %circumference)
print(" Area Of a Circle = %.2f" %area)
After executing the python program, the output will be:
Please Enter the radius of a circle: 56 Diameter Of a Circle = 112.00 Circumference Of a Circle = 351.86 Area Of a Circle = 9852.03