KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write a user-defined function def Circle() to input radius of a circle from the user. The program calculates area and circumference inside the function. Finally, it returns the values to main program to display the result.

Python Functions

1 Like

Answer

def Circle(r):
    ar = 3.14 * r * r
    cir = 2 * 3.14 * r
    return(ar, cir)

radius = float(input("Enter radius of circle:"))
area, circumference = Circle(radius)
print("Area of circle:", area)
print("Circumference of circle:", circumference)

Output

Enter radius of circle:7
Area of circle: 153.86
Circumference of circle: 43.96

Answered By

2 Likes


Related Questions