一、【python】计算各个健康情况的体重范围
1.1 效果演示

1.2 完整源代码
import sys
def BMIcounter():
print('根据BMI中国标准和身高计算出各个健康标准的体重范围')
try:
height = float(input('请输入身高(如1.7) :'))
except:
input('你输入了不正确的数值,请重新打开。')
sys.exit(1)
print('\n当小于{:.2f}kg时,您处于偏瘦状态'.format(18.4 * height ** 2))
print('当处于{:.2f}kg 和{:.2f}kg之间时,您处于正常状态'.format(
18.5 * height ** 2, 23.9 * height ** 2))
print('当处于{:.2f}kg 和{:.2f}kg之间时,您处于过重状态'.format(
24 * height ** 2, 27.9 * height ** 2))
print('当大于{:.2f}kg 时,您处于肥胖状态'.format(28 * height ** 2))
if __name__ == "__main__":
ifcontinue = True
while(ifcontinue):
BMIcounter()
strContinue = input('\n... input any key to exit! or input 1 to continue counting.')
ifcontinue = True if strContinue == '1' else False
参考博客
免费在线 BMI 计算器