Computer Science, asked by seeratjahan2704, 2 months ago



Question - VIII

Write a program to accept the length and breadth of a rectangle. Calculate and display the

area, perimeter or diagonal of the rectangle as per the user's choice.​

Answers

Answered by Equestriadash
5

The following cσdes have been written using Python.

l = float(input("Enter the length of the rectangle: "))

b = float(input("Enter the breadth of the rectangle: "))

print()

while True:

 print("1. Perimeter")

 print("2. Area")

 print("3. Diagonal")

 print("4. Exit")

 print()

 c = int(input("Enter your choice of calculation: "))

 print()

 if c == 1:

   p = 2*(l + b)

   print(p, "is the perimeter.")

   print()

 elif c == 2:

   a = l*b

   print(a, "is the area.")

   print()

 elif c == 3:

   d = (l*‎*2 + b*‎*2)*‎*(1/2)

   print(d, "is the diagonal")

   print()


Equestriadash: Kindly ensure not to give a space between the asterisks when running the program.
Similar questions