身体质量指数BMI
while True:
try:
s,t=eval(input("请输入身高,请输入体重:"))#检验数据是否存在异常
BMI=t/pow(s,2)
break
except NameError:#如果数据不是整数的话则报错
continue
print("BMI数值为:{:.2f}".format(BMI))
if BMI<18.5:
who,dom="偏瘦","偏瘦"
elif 18.5<=BMI<=23.9:
who,dom="正常","正常"
elif 24<=BMI<=24.9:
who,dom="正常","偏胖"
elif 25<=BMI<=27.9:
who,dom="偏胖","偏胖"
elif 28<=BMI<=29.9:
who,dom="偏胖","肥胖"
else:
who,dom="肥胖","肥胖"
print("BMI指标为:国际{},国内{}".format(who,dom))