Write a python program to calculate area of 10 different circles. Given the pie = 22/7 and radius of the circles entered by user using Simple Function , Parameterized Function , Return Type with function and return type with parameterized Functions .
Write a python program to calculate area of 10 different circles. Given the pie = 22/7 and radius of the …
Share
1.SIMPLE FUNCTION
def calculate_area():
pie = 22/7
for i in range(10):
radius = float(input(“Enter the radius of the circle: “))
area = pie * radius**2
print(“The area of the circle with radius”, radius, “is”, area)
calculate_area()
2. PARAMETERIZED FUNCTION
def calculate_area(radius):
pie = 22/7
area = pie * radius**2
return area
for i in range(10):
radius = float(input(“Enter the radius of the circle: “))
area = calculate_area(radius)
print(“The area of the circle with radius”, radius, “is”, area)
3. RETURN TYPE WITH FUNCTION
def calculate_area(radius):
pie = 22/7
area = pie * radius**2
return area
for i in range(10):
radius = float(input(“Enter the radius of the circle: “))
area = calculate_area(radius)
print(“The area of the circle with radius”, radius, “is”, area)
def get_circle_area(radius_list):
area_list = []
for radius in radius_list:
area = calculate_area(radius)
area_list.append(area)
return area_list
radius_list = []
for i in range(10):
radius = float(input(“Enter the radius of the circle: “))
radius_list.append(radius)
area_list = get_circle_area(radius_list)
for i in range(10):
print(“The area of the circle with radius”, radius_list[i], “is”, area_list[i])
4. Return type with parameterized function:
def calculate_area(radius):
pie = 22/7
area = pie * radius**2
return area
def get_circle_area(radius_list):
area_list = []
for radius in radius_list:
area = calculate_area(radius)
area_list.append(area)
return area_list
radius_list = []
for i in range(10):
radius = float(input(“Enter the radius of the circle: “))
radius_list.append(radius)
area_list = get_circle_area(radius_list)
for i in range(10):
print(“The area of the circle with radius”, radius_list[i], “is”, area_list[i])
FOLLOW THE BELOW LINK FOR THE ANSWER:
LINK->