Here,We are going to write python program to find diameter,circumference and area of circle using function . We can use some mathematical formulas to find diameter,circumference and area of circle. In this python program,We can create user defined function to calculate all this.

Write Python Program to find Diameter,Circumference and Area Of a Circle using function with a practical example.

The mathematical formulas are:

Diameter of a Circle = 2r = 2 * radius

Area of a circle is: A = πr² = 3.14 * radius * radius

Circumference of a Circle = 2πr = 2 * 3.14 * radius

Problem Description:

The program takes value of radius of circle from user and calculate Circumference, Diameter, and Area of a Circle using user defined function

Program Logic:

Take the values of radius of circle from the user using the float(input()) function and store it in variable say r.

Call function cal_Diameterand pass the value of radius as an argument to the cal_Diameter function.

Call function cal_Circumand pass the value of radius as an argument to the cal_Circum function.

Call function cal_Aresand pass the value of radius as an argument to the cal_Area function.

Create a user defined functions to say cal_Diameter,which takes the value of radius as an argument using def keyword and return calculated result.

Store result in variable say diameter.

Create a user defined functions to say cal_Circum, which takes the value of radius as an argument using def keyword and return calculated result.

Store result in variable say circumference.

Create a user defined functions to say cal_Area which takes the value of radius as an argument using def keyword and return calculated result.

Store result in variable say area

Print the variables diameter, circumference and area as output and exit.

Below is Implementation code/Source Code :

Here is source code of the Python Program to find Diameter Circumference and Area Of a Circle using function with a practical example. The program output is also shown below.

import math
def cal_Diameter(radius):
return 2 * radius
def cal_Circum(radius):
return 2 * math.pi * radius
def cal_Area(radius):
return math.pi * radius * radius
r = float(input("Enter the radius of a circle: "))
diameter = cal_Diameter(r)
circumference = cal_Circum(r)
area = cal_Area(r)
print("Diameter Of a Circle = %.2f" %diameter)
print("Circumference Of a Circle = %.2f" %circumference)
print("Area Of a Circle = %.2f" %area)