Question:
Write a program that prompts the user to input the length and the width of a rectangle and outputs the area and circumference of the rectangle.
The Formula is:
AREA = LENGTH * WIDTH
CIRCUMFERENCE = 2 (LENGTH + WIDTH)
Answer:
# Write a program that prompts the user to input the length and the width of a rectangle and
# outputs the area and circumference of the rectangle. The Formula is:
# AREA = LENGTH * WIDTH
# CIRCUMFERENCE = 2 (LENGTH + WIDTH)
def AreaOfRectangle(length, width):
print("Area of Rectangle with Length:",length,"and width:",width,"is:", length*width)
def CircumferenceOfRectanble(length,width):
circumference = 2*(length+width)
print("Circumference",circumference)
length1 = int(input("Enter the length of Rectangle:\n " ))
width1 = int(input("Enter the width of Rectangle:\n " ))
AreaOfRectangle(length1,width1)
CircumferenceOfRectanble(length1,width1)
Output of the Code
Thanks for reading. If you have difficulty running this code, please leave a comment and let us know.