+ 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")

19th Feb 2023, 4:12 AM
Michaela Rehm
Michaela Rehm - avatar
4 Réponses
+ 5
Change the order of data entry, weight is entered first, then height.
19th Feb 2023, 4:20 AM
Solo
Solo - avatar
+ 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..
19th Feb 2023, 11:42 AM
Mikhail
Mikhail - avatar
+ 1
Same here, non of the answers worked for me
20th Feb 2023, 11:45 PM
محمد عبد الله حطيبة
محمد عبد الله حطيبة - avatar
0
Multiply the height rather than using exponentials, the rest of the code looks good.
20th Feb 2023, 4:27 PM
Camelia
Camelia - avatar