Python实例5:身体质量指数BMI

代码实现:

height, weight= eval(input("请输入身高(米)和体重(千克)[用逗号隔开]:"))
BMI = weight / (height**2)
print("您的BMI指数为:{:.2f}".format(BMI))
nat, dom = "", ""
if BMI < 18.5:
    nat, dom = "偏瘦", "偏瘦"
elif 18.5 <= BMI < 24:
    nat, dom = "正常", "正常"
elif 24 <= BMI < 25:
    nat, dom = "正常", "偏胖"
elif 25 <= BMI < 28:
    nat, dom = "偏胖", "偏胖"
elif 28 <= BMI < 30:
    nat, dom = "偏胖", "肥胖"
else:
    nat, dom = "肥胖", "销售"
print("您的国际BMI指标是'{}',国内BMI指标是'{}'".format(nat, dom))

你可能感兴趣的:(py)