0

Python for beginners course bug?

I'm having troubles with project #26 the BMI calculator i think there maybe a bug or something I tried to write a code and after hour of it not working I googled it and it is the same as my code and it still doesn't work, last thing I did is copy/paste the Google code in case there is a hiding wrong thing I did but the result is the same as mine Which is the first test is correct and the rest are wrong.

8th Aug 2022, 5:42 PM
Ahmed Mahmoud
9 Respostas
+ 4
No, you need to test if bmi < 18.5, not if bmi <= 18.499. And you need to apply the same logic to the other conditions as well
8th Aug 2022, 6:42 PM
Lisa
Lisa - avatar
+ 4
You need to change it for EACH CONDITION of your code. Read the task description carefully
8th Aug 2022, 6:32 PM
Lisa
Lisa - avatar
+ 3
Siluppose bmi was 18.45. It is < 18.5 and should be Underweight. However your current code would mark it as Normal.
8th Aug 2022, 6:13 PM
Lisa
Lisa - avatar
+ 2
Can you please post your code, so we can see. Maybe even code you copied from google is not good, to pass sololearn test.
8th Aug 2022, 5:46 PM
PanicS
PanicS - avatar
+ 2
Ahmed Mahmoud after you have corrected the comparison thresholds, you must also corrected the inputs. Read carefully the input requirements. Weight comes first.
8th Aug 2022, 10:35 PM
Brian
Brian - avatar
0
height = float(input()) weight = float(input()) bmi = weight/height**2 if bmi <= 18.4: print("Underweight") elif bmi <= 24.9: print("Normal") elif bmi <= 29.9: print("Overweight") else: print("Obesity")
8th Aug 2022, 5:53 PM
Ahmed Mahmoud
0
This is my code and the result return valid for the first test case which is Underweight only For the second the expected is Obesity But it shows me that my output is Underweight So there is no spelling mistake or something like that it return different value
8th Aug 2022, 5:56 PM
Ahmed Mahmoud
0
Lisa yes. I edited my code but it didn't change anything still the first test case is True And the rest are False
8th Aug 2022, 6:27 PM
Ahmed Mahmoud
0
Lisa i did actually i made it .999 for evrey condition i can't post a picture here unfortunately, but the output of 2nd test case supposed to be Obesity but they say the output of my code outputted Underweight it can't be because of tiny difference like that
8th Aug 2022, 6:38 PM
Ahmed Mahmoud