0% found this document useful (0 votes)
23 views3 pages

Program 1

The document provides a Python program that defines three functions to calculate the area of a square, rectangle, and circle. It includes a menu for users to select which area to calculate and prompts for necessary dimensions. The program continues to run until the user chooses to exit.

Uploaded by

uma divan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Program 1

The document provides a Python program that defines three functions to calculate the area of a square, rectangle, and circle. It includes a menu for users to select which area to calculate and prompts for necessary dimensions. The program continues to run until the user chooses to exit.

Uploaded by

uma divan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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

You might also like