Python Function Circle Area – Write a Python program to input radius of a circle. Calculate the area of the circle with the given radius.
Source code for Python Program to find Area of Circle
# Python Function Area of Circle # Define the function to find area of circle def area_of_circle(radius): if radius < 0: print('Error: radius must be non-negative') return area = 3.14159 * radius**2 return area # input radius radius = float(input('Enter radius of circle: ')) # call the function passing radius as argument area = area_of_circle(radius) # print answer that is area of circle print('area of circle is: ', area)
Output
Enter radius of circle: 2.35
area of circle is: 17.349430775000002