0
Why isn't this code correct (code project BMI calculator)
weight=int(input()) height=int(input()) BMI=weight/(height**2)0 if BMI<18.5: print(Underweight) elif BMI>=18.5 and BMI<25: print(Normal) elif BMI>=25 and BMI<30: print(Overweight) elif BMI>=30 print(Obese)
1 Resposta
+ 2
Mikhael bin Mohd Rafee there are many mistakes in your code:
height must be float, not int, as expressed in meter... I think weight is always integer in tests, but safer to get it also as float ^^
there's an unexpected 0 at end of BMI assignation line
your if..elif block bodies must be indented
your last elif lacks the colon after condition
your print arguments must be enclosed by quotes (string literal)
your last print argument is mispelled
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")
elif BMI>=30:
print("Obesity")
anyway, you could avoid the last elif and use else (without condition), and you could have only one condition per elif (the 'lesser than' condition)