0

This one in python project. .. I've tried to solved (I think I did solved it) ...can you tell me what my wrong bugs please

height = float (input()) weight = 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")

1st Jan 2022, 4:17 AM
Musab Adam
Musab Adam - avatar
4 Answers
+ 7
The only real problem in your code that I see is that "Underweight" is output when BMI is *less than or equal to* 18.5. According to the task, it should be less than 18.5 to be Underweight and 18.5 is Normal. ANONYMOUS, sorry, but those all are not errors. You can freely insert any number of spaces in those places, it depends on the coding style of one whether the spaces are or are not there. [edit] The other problem is that you ask for height first and then for weight, while it should be vice versa. Sorry that I did not see it at first.
1st Jan 2022, 5:43 AM
#0009e7 [get]
#0009e7 [get] - avatar
+ 5
ANONYMOUS , all the *mistakes* about *spaces* that you mentioned have no influence on the correctness of the code.
1st Jan 2022, 10:16 AM
Lothar
Lothar - avatar
+ 3
Musab Adam w = float(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") elif bmi >= 30: print("Obesity") #try this
1st Jan 2022, 4:39 AM
NEZ
NEZ - avatar
+ 2
NEZ ..... Thanks a lot man ...it finally worked. ...💙
1st Jan 2022, 6:01 AM
Musab Adam
Musab Adam - avatar