Discuss / Python / 交作业

交作业

Topic source

承德沈楠

#1 Created at ... [Delete] [Delete and Lock User]

依题会产生等于临界数值时,跳出判断的问题。应该是,如:小于等于24.99,大于等于25的判断方法吧?鉴于练习题,主要看思路,就不改了。

height=float(input('请输入身高:'))
weight=float(input('请输入体重:'))
bmi=weight/(height*height)
print ('你的BMI值为:',bmi)
if bmi>32:
    print('严重肥胖')
elif bmi<=32 and bmi>=28:
    print('肥胖')
elif bmi<=28 and bmi>=25:
    print('过重')
elif bmi<=25 and bmi>=18.5:
    print('正常')
else:
    print('过轻')

  • 1

Reply