您的位置:首页 > 编程语言 > Python开发

中国大学 MOOC 课程 《Python 语言程序设计》 课后练习(第 4 周)

2017-12-02 22:55 651 查看

中国大学 MOOC 课程 《Python 语言程序设计》 课后练习(第 4 周)

weight=input("请输入你的体重:")
height=input("请输入你的身高:")
BMI=float(weight)/(float(height)**2)
x=["国内标准","国际标准"]
def china():
if BMI < 18.5:
print("你的BMI={0:.1f},偏瘦,{1}".format(BMI,x[0]))

elif BMI < 24 and BMI >=18.5:
print("你的BMI={0:.1f},正常,{1}".format(BMI,x[0]))

elif BMI < 28 and BMI >=24:
print("你的BMI={0:.1f},偏胖,{1}".format(BMI,x[0]))

elif BMI >= 28:
print("你的BMI={0:.1f},肥胖,{1}".format(BMI,x[0]))

def international():
if BMI < 18.5:
print("你的BMI={0:.1f},偏瘦,{1}".format(BMI,x[1]))

elif BMI < 25 and BMI >=18.5:
print("你的BMI={0:.1f},正常,{1}".format(BMI,x[1]))

elif BMI < 30 and BMI >=25:
print("你的BMI={0:.1f},偏胖,{1}".format(BMI,x[1]))

elif BMI >=30:
print("你的BMI={0:.1f},肥胖,{1}".format(BMI,x[1]))

china()
international()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: