15th Jan 2023, 10:50 AM
Wesam Hassan
Wesam Hassan - avatar
9 Respuestas
+ 7
Wesam Sobhy , (referring to your *updated code*) sorry to say, but the conditional expressions and the structure how they are ordered looks weird, so we can not pass the test cases. e.g.: weight = 130, height = 1.7 result is: Obesity Normal Overweight > instead of using individual *if...* we should use something like: *if... elif... else...* > also there is still a typo in an *if* > this is how it could be done: if BMI < 18.5: ... elif BMI >= 18.5 and BMI < 25: ... elif BMI >= 25.0 and BMI < 30: ... elif BMI >= 30.0: ... > i would recommend you to learn again about conditional statements before you continue with other stuff.
15th Jan 2023, 4:12 PM
Lothar
Lothar - avatar
+ 3
There are several issues: * The division operator in Python is "/", not "\" * The output must be strings. Strings have quotation marks around it. Compare "Underweight" vs. Underweight. Also check for typos. * Look up how conditions are chained in Python. * Suppose the BMI was 18. Your current code would output Underweight as well as Obesity which shouldn't be true.
15th Jan 2023, 10:59 AM
Lisa
Lisa - avatar
+ 2
Please show your updated code.
15th Jan 2023, 11:30 AM
Lisa
Lisa - avatar
+ 2
Wesam Sobhy check output for BMI 30 by going through your code. Last 3 conditions met true.
15th Jan 2023, 1:01 PM
Jayakrishna 🇮🇳
+ 1
weight= 0 hight= 0 weight = int (input()) hight= float (input ()) BMI= weight / hight**2 if BMI < 18.5 : print ("Underweight") If BMI>= 30: print ("Obesity") if BMI>= 18.5<25: print ("Normal ") if BMI>=25<30: print ("Overweight ")
15th Jan 2023, 11:38 AM
Wesam Hassan
Wesam Hassan - avatar
+ 1
Ok
15th Jan 2023, 4:16 PM
Wesam Hassan
Wesam Hassan - avatar
+ 1
Thank you
15th Jan 2023, 4:16 PM
Wesam Hassan
Wesam Hassan - avatar
0
I have two wrong answers, which are, BMI = 44.9 and BMI = 26 How can I solve them please The other three outputs are right Thanks in advance
15th Jan 2023, 11:27 AM
Wesam Hassan
Wesam Hassan - avatar
0
The division operator is wrong. The print statements have no quotations. The naming for height is quite weird. I think you should use and operator.
16th Jan 2023, 1:32 PM
Mcmc
Mcmc - avatar