python实现BMI计算器

#BMICalculator
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 = "偏胖","肥胖"

print(who,nat)

本文分享了一个逻辑结构很简单的BMI计算器,感谢学习强国-慕课-python。笔者曾写过一个实现类似功能的微信小程序,步骤整理如下:

写文章-CSDN创作中心

你可能感兴趣的:(仰望IT天空——Python,python)