废话不多说,直接上程序哈:
name=input('Name:')
height=input('Height(m):')
weight=input('Weight(kg):')
BMI=float(float(weight)/(float(height)**2))
print('您的BMI指数为:',BIM)
if BMI <18.5:
print('你太轻了!')
elif BMI<=25:
print('标准体重哦哦!')
elif BMI<=32:
print('您有点微胖哦哦!')
else:
print('您太胖了,该减肥了')
废话不多说,改进版继续上程序哈:
def bmi():
name=input('Name:')
height=input('Height(m):')
weight=input('Weight(kg):')
BIM=float(float(weight)/(float(height)**2))
print('您的BIM指数为:',BIM)
if BIM <18.5:
print('你太轻了!')
elif BIM<=25:
print('标准体重哦哦!')
elif BIM<=32:
print('您有点微胖哦哦!')
else:
print('您太胖了,该减肥了')
bmi()
for i in range(10):
choose =input('您是否愿意继续计算BMI(y/n):')
if choose=='y':
bmi()
else:
break