Programming Examples

Python program to display menu to calculate area of square or rectangle


Program to display menu to calculate are of square or rectangle 

Solution

print("1. Calculate area of square")
print("2. Calculate area of rectangle ")
choice= int(input(" Enter your choice (1 or 2):"))
if(choice==1):
             side=float(input("Enter side of a square :"))
             area_square=side*side
             print("Area of square is:",area_square)
else:
                length=float(input(" Enter length of a rectangle:"))
                breadth=float(input("Enter breadth of a rectangle:"))
                area_rectangle=length*breadth
                print("Area of a rectangle is :", area_rectangle)
Output

Output  1:

1. Calculate area of square

2. Calculate area of rectangle 

 Enter your choice (1 or 2):1

Enter side of a square :2.5

('Area of square is:', 6.25)



Output 2:
1. Calculate area of square

2. Calculate area of rectangle 

 Enter your choice (1 or 2):2

 Enter length of a rectangle:8

Enter breadth of a rectangle:4

('Area of a rectangle is :', 32.0)

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz