+ 1
In section 28, i cant figure where's the problem?
#i write this code to calculate the BMI def bmi_calculator(Weight,Hight): Bmi = Weight/(Hight*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") bmi_calculator(52,1.85) #someone know thw solution?
4 Antworten
+ 2
Hey,
First of all, your formula is wrong.
The BMI is being calculated as the following:
BMI = (weight / height / height) * 10000
Or simplified:
BMI = (weight/height**2)* 10000
2) You should pass the height in centimeters to the function like 185 and not in meter like 1.85. Since 1.85 is basically ~2 and not 185, that's because of the dot. If you would like to pass meters you should change the formula to:
BMI = ((weight*100)/height**2)* 10000
Here is as example:
If you call the function with (52, 185), here is what happens:
BMI = (52 / 185**2)*10000
> BMI = 15.2
> underweight
I hope you understand it.
+ 2
Thanks bro, i will try iy
+ 1
Hey,
Your BMI formula is incorrect, as well as your function input. Here is the correct way of doing it:
def bmi_calculator(Weight,Hight):
Bmi = (Weight/(Hight**2)) * 10000
if Bmi > 30:
print("obesity")
elif Bmi >= 25:
print("overweight")
elif Bmi >= 18.5:
print("normal")
else:
print("underweight")
bmi_calculator(52, 185)
0
Thanks but i got the same result l, it's always wrong