76 409
Assignments Done
Successfully Done
In May 2019

Answer to Question #35454 in Python for Ashley

Question #35454
The area of a rectangle is the rectangle's length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area or if the areas are the same.
Expert's answer
#!/usr/bin/env python
import sys

width1 = input("Enter the width of the first rectangle: ")
height1 = input("Enter the height of the first rectangle: ")
width2 = input("Enter the width of the second rectangle: ")
height2 = input("Enter the height of the second rectangle" ")
print "You should enter only numbers!!!"

area1 = width1 * height1
area2 = width2 * height2

print "Area of the first rectangle is ", area1
print "Area of the second rectangle is ", area2

if area1 > area2:
print "The first rectangle is bigger"
elif area1 < area2:
print "The second rectangle is bigger"
print "Rectangles are equal"

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions