身体质量指数 (Body Mass Index, 简称BMI), 亦称克托莱指数, 是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。BMI 值超标,意味着你必须减肥了。

在线版:https://cn.onlinebmicalculator.com/

【Python】BMI指数 计算器_python

 

 代码:

height,weight=eval(input("请输入身高(米)和体重\(公斤)[用逗号隔开]:"))
bmi=weight/pow(height,2)
print("BMI数值为:(:.2f)".format(bmi))
who,nat="",""
if bmi<18.5:
    who,nat="偏瘦","偏瘦"
elif 18.5<=bmi<24:
    who,nat="正常","正常"
elif 24<=bmi<25:
    who,nat="正常","偏胖"
elif 25<=bmi<28:
    who,nat="偏胖","偏胖"
elif 28<=bmi<30:
    who,nat="偏胖","肥胖"
else:
    who,nat="肥胖","肥胖"

print("BMI 指标为国际'{0}',国内'{1}'".format(who,nat))

结果:

【Python】BMI指数 计算器_python_02