+ 1
Python BMI calculator
Hi all, So my code is always returning "Underweight" and I'm not sure why. I tried putting in print(x) to see what the calculation came out with, and I'm getting extremely small decimals. Can anyone tell me why? height = float(input()) weight = float(input()) x = weight/(height**2) if x < 18.5: print("Underweight") elif x >= 18.5 and x < 25: print("Normal") elif x >= 25 and x < 30: print("Overweight") else: print("Obesity")
4 Answers
+ 5
Change the order of data entry, weight is entered first, then height.
+ 1
Michaela Rehm,
tell me how you enter the parameters of height and weight?
Remember, weight in kilograms, height in meters (for example: 190 cm. = 1.9 m.)
If you enter height in centimeters the value of the variable "X" will be extremely small..
+ 1
Same here, non of the answers worked for me
0
Multiply the height rather than using exponentials, the rest of the code looks good.