我有一个(简单的)脚本:
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))
例如,长度= 43,宽度= 17,我得
但是对于比率,我得到2.000,虽然我应该有2.529
我哪里出错了?
提前致谢