+ 4
Why is BMI calculator not correct?
My BMI calc runs correctly but not considered correct https://code.sololearn.com/cfdApuwt53AV/?ref=app
20 Antworten
+ 11
David Nyang Touric Chap Remove 4th line and if you want to check a no in range then check it as a<no<=b or [no>a and no<=b] not as no<a<=b
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')
else:
print ('Obesity')
+ 4
David Nyang Touric Chap ,
Can you be a bit more specific? what is the problem?
please give us input values and the output, and what you are expecting.
thanks for your understanding!
+ 4
Did you make changes in the comparison?
See my code in the 6th,8th and 10th lines. You can paste and see🌝
+ 4
Boolean operater are not used in this program.Use and operater in this program.
+ 3
David Nyang Touric Chap ,
Can you be a bit more specific? what is the problem?
please give us input values and the output, and what you are expecting.
thanks for your understanding!
+ 3
David Nyang Touric Chap Remove 4th line and if you want to check a no in range then check it as a<no<=b or [no>a and no<=b] not as no<a<=b
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')
else:
print ('Obesity')
+ 2
Aditya
I removed 4th line but still not correct
+ 2
Put this after line 3
print(BMI)
You will see why you are having problems
+ 2
This is formula for measuring BMI.
Calculation: [weight (lb) / height (in)]^2 x 703
So your program should be like this.
weight_IB = int(input())
height_in = float(input())
BMI = weight_IB / ( height_in)**2 * 703
Then use conditions and for comparison use range function.
Like between 18 and 25 use
BMI in range (18,25)
+ 2
https://code.sololearn.com/cKBK5AovGcGg/?ref=app
Check out this.
+ 2
Doesn’t define units of measurement, I wrote it in Kg and Cm
+ 2
Height=float(input("Enter your height in centimeters: "))
Weight=float(input("Enter your Weight in Kg: "))
Height = Height/100
BMI=Weight/(Height*Height)
print("your Body Mass Index is: ",BMI)
if(BMI>0):
if(BMI<=16):
print("you are severely underweight")
elif(BMI<=18.5):
print("you are underweight")
elif(BMI<=25):
print("you are Healthy")
elif(BMI<=30):
print("you are overweight")
else:
print("you are severely overweight")
else:("enter valid details")
+ 2
You're just missing the "and" operator, and it's better to make the weight a float. Also, to make your code shorter and more efficient, remove the elif that prints "Obesity", since every other result that's not covered will be considered Obesity, so just put
else:
print("Obesity")
Otherwise, the rest of your code is good.
weight = float(input())
height = float(input())
BMI = weight / (height)**2
#print (f"you BMI is {BMI}")
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")
+ 2
😯😯
+ 2
Read code
+ 2
Understand the question first and rewrite all the conditions. Mention that both height and weight are floats in your code and do not assign any values to height and weight.Just enter the limit of your code.
Here's the code follows as:
w=float(input())
h=float(input())
bmi=w/(h**2)
if bmi < 18.5:
print("Underweight")
elif 18.5 <= bmi <25:
print("Normal")
elif 25 <= bmi<=30:
print("Overweight")
else:
print("Obesity")
+ 1
bmi = weight / (height *height)
+ 1
a = int(input())
b = float(input())
x = a/(b*b)
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")
0
Lother
Input is 52
1.85
Expected result is "underweight"
0
#your code goes here
weight = float(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('Obesity')
Copy and paste my answer
If it is right please vote for me