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.
1
Expert's answer
2013-09-27T08:45:07-0400
#!/usr/bin/env python import sys
try: 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" ") except: print "You should enter only numbers!!!" sys.exit()
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" else: print "Rectangles are equal"
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment