+ 1
Lesson 28 module project
Hello guys, can anyone help to understand why one of the locked test cases fail #3 to be exact fr BMI calculator. All other test cases are pass, but the #3 and I don’t know why. My code is as follows: #your code goes here userWeight = input() # in whole kg userHeight = input() # metre.cm BMI = int(userWeight) // (float(userHeight)*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")
3 Antworten
+ 1
Hi Evaldas, I think I see the problem here. In the BMI variable definition, you have used //. The problem with that, is that it outputs an integer, although perhaps in float type, as it is how many times the height^2 goes in fully. So that is one thing, as rounding can perhaps narrowly push into wrong boundaries. The other is that you have timesed the height by two instead of put it to the power of two. Remember * is multiply and ** is exponentiation! Hopefully this helps. (One quick tip, you could use, but don't have to, on the last elif, you can just make it else, that is the same statement). Anyways, happy coding!
0
thank you guys