Discuss / Python / 有点小疑问

有点小疑问

Topic source

赵越-Alex

#1 Created at ... [Delete] [Delete and Lock User]
he = input('height:')
h = float(he)
we = input('weight:')
w = float(we)
bmi=w/(h*h)
if bmi<18.5:
    print('过轻')
elif bmi<25:
    print('正常')
elif bmi<28:
    print('过重')
elif bmi<32:
    print('肥胖')
elif bmi>32:
    print('严重肥胖')

float那里确实很操蛋,应该注意一下的。 也不清楚为什么不能用h^2这种表示方式。如果一个公式出现了h的一万次方怎么办?

h2,代表次方

用2次乘号代表次方

代码挺赞的,谢谢哦,没想到float

貌似代码有个BUG


  • 1

Reply