Lesson 28 module project | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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")

12th Mar 2021, 9:49 AM
Evaldas Oleinikas
Evaldas Oleinikas - avatar
3 Answers
12th Mar 2021, 9:58 AM
!Derrickee
!Derrickee - avatar
+ 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!
12th Mar 2021, 10:01 AM
Kamil Hamid
Kamil Hamid - avatar
0
thank you guys
12th Mar 2021, 11:59 AM
Evaldas Oleinikas
Evaldas Oleinikas - avatar