Question #46578

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 users which rectangle has greater area, or if the area is same

Expert's answer

Answer on Question#46578 - Programming - Python

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 users which rectangle has greater area, or if the area is same.

Answer


#!/usr/bin/python
a1 = int(raw_input("Please, enter rectangle 1 width:"))
b1 = int(raw_input("Please, enter rectangle 1 length:"))
a2 = int(raw_input("Please, enter rectangle 2 width:"))
b2 = int(raw_input("Please, enter rectangle 2 length:"))
if a1*b1 > a2*b2:
    print "Rectangle 1 has larger square"
elif a1*b1 < a2*b2:
    print "Rectangle 2 has larger square"
else:
    print "Rectangles have equal squares"


http://www.AssignmentExpert.com/

LATEST TUTORIALS
APPROVED BY CLIENTS