PROGRAM-1
Q. Write a program in python to define three functions to calculate the area of various shapes like
square, rectangle and circle and invoke these functions inside a menu as follows.
**MENU**
1. Area of square
2. Area of rectangle
3. Area of circle
CODE:-
print('''**MENU**
1. Area of Square
2. Area of Rectangle
3. Area of Circle
4. Exit''')
def areasq():
side=int(input("Enter the side of the square:"))
return side**2
def arearec():
length=int(input("Enter the length of the rectangle:"))
breadth=int(input("Enter the breadth of the rectangle:"))
return length*breadth
def areacir():
radius=int(input("Enter the radius of the circle:"))
return 3.14*(radius**2)
while True:
choice=int(input("Choose an option:"))
if choice==1:
print(‘Area of the square:’,areasq())
elif choice==2:
print(‘Area of the rectangle:’arearec())
elif choice==3:
print(‘Area of the Circle:’areacir())
else:
break
OUTPUT:-
**MENU**
1. Area of Square
2. Area of Rectangle
3. Area of Circle
4. Exit
Choose an option:1
Enter the side of the square:2
Area of the Square:4
Choose an option:2
Enter the length of the rectangle:2
Enter the breadth of the rectangle:4
Area of the Rectangle:8
Choose an option:3
Enter the radius of the circle:2
Area of the Circle:12.56
Choose an option:4