name = input("请输入你的名字:")
age = int(input("请输入你的年龄:"))
height = float(input("请输入你的身高:"))
weight = float(input("请输入你的体重:"))
bmi = weight/(height*height)*10000
if bmi<18.5:
health = too_thin
elif 18.5<=bmi<25:
health = normal
elif 25<=bmi<28:
health = heavy
elif 28<=bmi<32:
health = fat
else:
health = too_fat
print("你好,%s,你的年龄是%d,经过科学的计算,你的bmi值是%f,属于%s"%(name,age,bmi,health))
运行这段代码的时候,当health值属于哪个区间的时候,就会报那个区间的赋值没有定义,请问各位大神,这是肿么回事。。。
age = int(input("请输入你的年龄:"))
height = float(input("请输入你的身高:"))
weight = float(input("请输入你的体重:"))
bmi = weight/(height*height)*10000
if bmi<18.5:
health = too_thin
elif 18.5<=bmi<25:
health = normal
elif 25<=bmi<28:
health = heavy
elif 28<=bmi<32:
health = fat
else:
health = too_fat
print("你好,%s,你的年龄是%d,经过科学的计算,你的bmi值是%f,属于%s"%(name,age,bmi,health))
运行这段代码的时候,当health值属于哪个区间的时候,就会报那个区间的赋值没有定义,请问各位大神,这是肿么回事。。。