#Radius Pre-Define(in the program) by user..
import math
def calculate_circle_area(radius):
area = math.pi * (radius ** 2)
return area
def calculate_circle_area(radius):
area = math.pi * (radius ** 2)
return area
# Example usage
radius = 5.5
area = calculate_circle_area(radius)
print("The area of the circle with radius", radius, "is:", area)
area = calculate_circle_area(radius)
print("The area of the circle with radius", radius, "is:", area)
Output:
The area of the circle with radius 5.5 is: 95.03317777109125
The "calculate_circle_area" function in this programme accepts the radius of the circle as input and calculates the area using the formula "pi * radius^2". The constant "math.pi" is used to represent the mathematical value of pi.
As an example, in the sample use, we set the "radius" variable to 5.5. The programme then uses the specified radius to run the "calculate_circle_area" function, which returns the result in the "area" variable. Finally, it uses the "print" function to output the radius and computed area.
#Radius Post-Define(input after the run Program) by user..
import math
def calculate_circle_area(radius):
area = math.pi * (radius ** 2)
return area
radius = float(input("Enter the radius of the circle: "))
area = calculate_circle_area(radius)
print("The area of the circle is:", area)
Output:
Enter the radius of the circle: 5.5
The area of the circle is: 95.03317777109125