+ 4

Why is BMI calculator not correct?

My BMI calc runs correctly but not considered correct https://code.sololearn.com/cfdApuwt53AV/?ref=app

19th May 2021, 9:54 AM
David Nyang Touric Chap
David Nyang Touric Chap - avatar
20 Réponses
+ 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')
19th May 2021, 10:06 AM
Aditya
Aditya - avatar
+ 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!
19th May 2021, 10:01 AM
Lothar
Lothar - avatar
+ 4
Did you make changes in the comparison? See my code in the 6th,8th and 10th lines. You can paste and see🌝
19th May 2021, 10:20 AM
Aditya
Aditya - avatar
+ 4
Boolean operater are not used in this program.Use and operater in this program.
20th May 2021, 1:22 PM
RUDRA PRATAP CHAUHAN
RUDRA PRATAP CHAUHAN - avatar
+ 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!
20th May 2021, 3:32 PM
JTB Coder
JTB Coder - avatar
+ 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')
20th May 2021, 3:33 PM
JTB Coder
JTB Coder - avatar
+ 2
Aditya I removed 4th line but still not correct
19th May 2021, 10:13 AM
David Nyang Touric Chap
David Nyang Touric Chap - avatar
+ 2
Put this after line 3 print(BMI) You will see why you are having problems
19th May 2021, 11:26 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 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)
20th May 2021, 6:07 AM
Hamza Malik
Hamza Malik - avatar
20th May 2021, 8:57 AM
Utsab Dahal
Utsab Dahal - avatar
+ 2
Doesn’t define units of measurement, I wrote it in Kg and Cm
20th May 2021, 2:44 PM
Will Freeman
+ 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")
20th May 2021, 2:48 PM
Saber Ahmadzai
Saber Ahmadzai - avatar
+ 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")
20th May 2021, 2:51 PM
Sebastien Abainza
Sebastien Abainza - avatar
+ 2
😯😯
20th May 2021, 5:06 PM
Nirmal Choudhary
+ 2
Read code
20th May 2021, 6:36 PM
Dianbobo Bah
Dianbobo Bah - avatar
+ 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")
21st May 2021, 8:43 AM
dv charitha
dv charitha - avatar
+ 1
bmi = weight / (height *height)
21st May 2021, 2:59 AM
Kipkorir Gideon
Kipkorir Gideon - avatar
+ 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")
21st May 2021, 3:01 AM
Kipkorir Gideon
Kipkorir Gideon - avatar
0
Lother Input is 52 1.85 Expected result is "underweight"
19th May 2021, 10:09 AM
David Nyang Touric Chap
David Nyang Touric Chap - avatar
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
19th Aug 2021, 7:21 AM
Sariga.S