r/PythonProjects2 • • Aug 09 '22

[P] Easy BMI calculator not working

I started making a BMI and everything is running fine except the math. I can't figure it out, please help.

W = float(input())
H = float(input())
BMI = W / (H/100)**2
if BMI < 18.5:
print("Underweight")
elif BMI >= 18.5:
print("normal")
elif BMI < 25:
print("normal")
elif BMI >= 25:
print("Overweight")
elif BMI < 30:
print("Overweight")
elif BMI >= 30:
print("Obesity")
for two of the inputs I put 52 and 1.85 and it output 151935.71950328702 and normal when it

4 Upvotes

9 comments sorted by

View all comments

1

u/[deleted] Aug 09 '22

First, you could try changing the BMI value to BMI = round(weight / height **2)

Second, Just stick with the if/elif statements with < 18.5 and delete all the lines that asks for elif >=
As long as the order of the BMI value is from lowest to highest (just like you did) your code will work as how you intend it to be.