我想为学校做这个练习,但代码将无法正常工作,恰恰它不执行if语句后计算BMI。此外,如果输入不正确,现在检查除了状态。请告知代码中需要更正的内容。谢谢!尝试,除了和while循环在Python
user_input_1 = input('What is your weight')
user_input_2 = input('What is your height')
b = 'BMI'
b = int(user_input_1)/(float(user_input_2)**2)
while True:
try:
user_input_1 == int and user_input_1 > 0
user_input_2 == float and user_input_2 > 0
print(b)
if b in range(1, 19):
print('You are skinny as a rail')
break
if b in range(19, 26):
print('You are fit as a butcher\'s dog')
break
if b >= 25:
print('You are as plum as a partridge')
break
break
except ZeroDivisionError:
input('Enter your height in meters as a float')
except user_input_1 != int:
input('Please enter your weight in kg')
我们不应该做人民的功课他们,而是只给指针。 此外,在这种情况下循环可能比递归更好。 – SpoonMeiser