BMI calculator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

BMI calculator

Someone help me out. I tried running this project and one of the test is still wrong...and I can't find the bug. w = int(input()) h = float(input()) BMI = w/h**2 if BMI <= 18.4: print("Underweight") elif BMI <= 24.9: print("Normal") elif BMI <= 29.9: print("Overweight") elif BMI >= 30: print("Obesity")

13th Jul 2021, 10:40 AM
Ejeh Joseph
Ejeh Joseph - avatar
4 Answers
+ 3
w = int(input()) h = float(input()) BMI = w/h**2 if BMI <= 18.4: print("Underweight") elif BMI <= 24.9: print("Normal") elif BMI <= 29.9: print("Overweight") elif BMI > 30: print("Obesity") It should be greater than 30 and not equal to. I hope you understand my point. Now you try it once again!!
13th Jul 2021, 10:53 AM
Aysha
Aysha - avatar
+ 2
Your problem is associated with your declarations of weight. IE: if BMI <= 18.4, etc. the challenge specifies if BMI <18.5. So if BMI == 18.475 Your code will return "Normal" instead of "Underweight" Write your code to reflect the challenge parameters. Good luck!
13th Jul 2021, 11:37 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Thank you so much Rik Wittkopp I have gotten it correctly... weight = int(input()) height = 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') elif bmi >= 30: print('Obese')
13th Jul 2021, 5:42 PM
Ejeh Joseph
Ejeh Joseph - avatar
0
It still has bug..it is project 28 in Python... But when I run the code in pydriod programming or anaconda, it runs completely
13th Jul 2021, 11:03 AM
Ejeh Joseph
Ejeh Joseph - avatar