1

I have a (simplistic) script :

length = int(input("Length ? "))
width = int(input("Width ? "))
area = int(length * width)
perimeter = int(2 * (length + width))
ratio = float(length/width)

print "The area is", area
print "and the perimeter", perimeter
print("for a ratio L/W of {0:.3f}".format(ratio))

For, e.g., length = 43 and width =17, I get

  • area = 731 (which is OK),
  • perimeter =120 (ditto),

but for the ratio, I get 2.000, although I should have 2.529

Where did I go wrong ?

Thanks in advance

ThG
  • 2,361
  • 4
  • 22
  • 33

0 Answers0