+ 1
My BMI Calculator needs help!
I have been stuck on this for days. PLEASE help!!!! weight=float(input()) height=float(input())*1000 BMI= weight/(height/100)**2 if BMI<=18.4: print('Underweight') elif BMI<=24: print("Normal") elif BMI<=29: print("Overweight") elif BMI>=30: print("Obesity") 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
9 Réponses
+ 4
Recode, change first condition => if BMI < 18.5, second condition => elif BMI < 25, third...... < 30.
+ 1
https://www.sololearn.com/discuss/2687547/?ref=app
https://www.sololearn.com/discuss/2686011/?ref=app
https://www.sololearn.com/discuss/2776665/?ref=app
https://www.sololearn.com/discuss/2940297/?ref=app
https://www.sololearn.com/discuss/2788765/?ref=app
https://www.sololearn.com/discuss/2686226/?ref=app
https://www.sololearn.com/discuss/2892961/?ref=app
+ 1
Input seems confusing.
And as you wrote under your code:
The 'Normal' and 'Overweight' are in between 2 values. (Example: 18,5 < BMI <= 24 then Normal ) You should put 'and' in your code twice.
+ 1
I did:
weight = int(input())
height = float(input())
bmi = weight / height**2
This got me my variables. Then, you just specify conditions.
0
its still broken, it calculates all as underweight
0
'Normal' and 'Overweight' cases have upper and lower limits.In ur code only upper limit is considered.Try the same.
Good wishes
0
Recode upon input you multiply height by 1000 (why?). Then in the final calculation you intended to restore it by dividing by 1000, however there is a typographical error and it divides by 100 instead of 1000. This causes the first condition always to be true, except for some ridiculous inputs.
Also fix the range limits in your program. For instance, by comparing BMI<=24, there is a gap between 24 and 25 where your result is wrong. Why not use the proper limits as given in the task description (e.g., BMI<25)?
0
https://code.sololearn.com/cBKB3ew0qj0r/?ref=app
This is my bmi calculator, try it! Your code has the many errors, like the formula, the booleans and if you are doing it for your code project in Python for beginners, you don't need to convert input to float and you can convert to int, but I let u copy-paste from me and check the errors
0
#check out my code
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")
elif bmi>=30:
print("Obesity")