Write a menu-driven program to accept the length and breadth of a rectangle and find the 1) Area 2) Perimeter
Answers
Answered by
0
to accept lenght and breadth of a rectangle (1) area
Answered by
3
Python program
print("Type 1 to calculate rectangle area and perimeter and 2 to exit")
menu = input(''Enter what you want to do: ")
if(menu == '1'):
length = float(input("Enter length of the rectangle: "))
breadth = float(input("Enter breadth of the rectangle: "))
area = length * breadth
perimeter = 2*(length + breadth)
print("The area of the rectangle is", area)
print("The perimeter of the rectangle is", perimeter)
elif(menu == '2'):
input() #to exit out of the console
else:
print("Error")
input() # to exit out of the console
Similar questions