217k views
0 votes
python write a program that ask the user to enter the length and width of a rectangle, then displays the area and the perimeter of the rectangle.

User Weeble
by
7.0k points

1 Answer

2 votes

# Program to find the area and perimeter of a rectangle

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

width = float(input("Enter the width of the rectangle: "))

# Calculate the area

area = length * width

# Calculate the perimeter

perimeter = 2 * (length + width)

# Display the results

print("Area of the rectangle:", area)

print("Perimeter of the rectangle:", perimeter)

This program will ask the user to enter the length and width of a rectangle as inputs, then calculates the area and perimeter using the formulas area = length * width and perimeter = 2 * (length + width), respectively. Finally, it prints the results of area and perimeter.

User Gonjay
by
7.9k points