image.png
用程序判断国际国内BMI:
height,weight=eval(input("please input your body height(m) and weight(kg)[splited by ',']:"))
BMI=weight/(height**2)
print("your BMI is :{:.2f}".format(BMI))
who,nat="",""
if 18.5>BMI:
who,nat="thin","thin"
elif 24>BMI>=18.5:
who,nat="normal","normal"
elif 25>=BMI>=24:
who,nat="normal","a little fat"
elif 28>BMI>=25:
who,nat="a little fat","a little fat"
elif 28>=BMI>25:
who,nat="a little fat","very fat"
elif BMI>=30:
who,nat="very fat","very fat"
print("international BMI is '{0}',national BMI is '{1}' !".format(who,nat))
output result:
please input your body height(m) and weight(kg)[splited by ',']:1.74,74
your BMI is :24.44
international BMI is 'normal',national BMI is 'a little fat' !