参考点
if分支结构
height,weight=eval(input("请输入身高(米),体重(kg)并用逗号隔开")) #因前面height和weight用逗号分隔
bmi=weight/pow(height,2)
print("BMI为:{:.2f}".format(bmi))
nation,china="","" #为了方便在这里先指出变量
if bmi<18.5:
nation,china="偏瘦","偏瘦"
elif 18.5<=bmi<=24:
nation,china="正常","正常"
elif 24<=bmi<25:
nation,chian="正常","偏瘦"
elif 25<=bmi<28:
nation,chian="偏胖","偏胖"
elif 28<=bmi<30:
nation,china="偏胖","肥胖"
else:
nation,china="肥胖","肥胖"
print("BMI国际准则为'{}',国内准则为'{}'".format(nation,china))
结果展示:
请输入身高(米),体重(kg)并用逗号隔开1.86,62
BMI为:17.92
BMI国际准则为'偏瘦',国内准则为'偏瘦'