代码如下:
Weight = float(input("Enter weight in Kilograms: "))
Height = float(input("Enter height in meters: "))
BMI = (Weight / (Height**2))
print ("%.2f" %BMI)
if BMI < 18.5:
print ("You are under weight")
elif BMI >= 18.5 and < 25.0:
print ("You weight is normal")
elif BMI >= 25.0 and < 30.0:
print ("You are overweight")
elif BMI >= 30.0:
print ("You are overweight")
获取行处的语法无效 elif BMI>;=18.5和25.0:
>
,<
,其余都是二进制运算符。它在每边寻找一个操作数,当它在左边找到一个关键字时and < 25.0
抛出一个SyntaxError
。在通常的方法是:
但不平等有捷径:
^{pr2}$相关问题 更多 >
编程相关推荐