+ 1
Phyton BMI Calculator Test Case 3 incorrect
My code is: weight = int(input()) height = float(input()) BMI = weight/height**2 if BMI < 18.5: print('Underweight') elif (BMI >= 18.5) and (BMI < 30): print("Normal") elif (BMI >= 25) and (BMI < 30): print('Overweight') else: print('Obesity') My question is why is test case 3 wrong? Even though I used someone's code which is VERY-SIMILAR to mine. This is the code from someone I copied: w = int(input()) h = float(input()) bmi = w / h**2 if bmi < 18.5: print("Underweight") elif bmi >= 18.5 and bmi < 25: print("Normal") elif bmi >= 25 and bmi < 30: print("Overweight") else: print("Obesity")
3 Antworten
+ 3
It's clearly showing your condition for "Normal" Condition is different than others.. ! Check again clearly..
edit:
bmi < 25 . but yours bmi < 30
0
weight = float(input(''))
height = float(input(''))
bmi = weight / (height ** 2)
if bmi < 18.5:
print('Underweight')
elif bmi >= 18.5 and bmi < 25:
print('Normal')
elif bmi >= 25 and bmi < 30:
print('Overweight')
else:
print('Obesity')
0
Thanks for the explanation @jaya! Btw how long have you been in sololearn to learn all that languages?