+ 4
Where am I going wrong with this module (BMI Calculator)?
BMI Calculator weight=float(input()) height=float(input()) BMI=weight/(height/100)**2 if BMI<18.5: print("Underweight") elif BMI>=18.5 and BMI<25: print("Normal") elif BMI>=25 and BMI<30: print("Overweight") else: print("Obesity")
11 Answers
+ 4
Actually, I don't see what's wrong with it... You know that formula uses kg and cm, yes?
+ 4
The formula need is
BMI = weight / height**2 #not /100
+ 4
Jayakrishna🇮🇳 CODIBILITY That's only true if you're using meters. If he's using centimeters, the divide by 100 is correct.
+ 3
weight = int(input())
height = float(input())
BMI = weight /(height ** 2)
if BMI < 18.5:
print("Underweight")
elif BMI < 25:
print("Normal")
elif BMI < 30:
print("Overweight")
else:
print("Obesity")
+ 2
Caroline Russell yes. But this code is about python BMI code coach. And description stated the details clearly with formula to be used..
"BMI Calculator:
Tracking your BMI is a useful way of checking if you’re maintaining a healthy weight. It’s calculated using a person's weight and height, using this formula: weight / height² 👈
The resulting number indicates one of the following categories:
Underweight = less than 18.5
Normal = more or equal to 18.5 and less than 25
Overweight = more or equal to 25 and less than 30
Obesity = 30 or more
Let’s make finding out your BMI quicker and easier, by creating a program that takes a person's weight and height as input and outputs the corresponding BMI category.
Sample Input
85
1.9
Sample Output
Normal
"
So that's about my reply..
+ 1
Dianah Delisile There is no && operator in python.
+ 1
Jayakrishna🇮🇳 Ah, I didn't know what module OP was referring to. Thanks.
0
Mark Leslie Heffernan I don't see anything wrong either. What is the expected behaviour and what happens instead?
- 1
I dont speak good english, but in ur code change the command "and" for "or" and enjoy
- 2
"and", its suppose to be && conditional operator
- 2
Try, elif 18.5 <= BMI < 25: elif 25 <= BMI < 30 , otherwise it's your conditional if operator nesting