0
I tried a lot but i couldn't complete the BMI calculator code. Please help. How can I solve it?
7 Respostas
+ 5
Problem solved.
David Ashton sir and đ
°đ
č đ
đ
đ
đ
đ
Ł sir thanks for your help. It worked. Thanks alot.
+ 6
You forgot to capitalize "Underweight"
Here's mine
weight, height = int(input()), 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")
+ 5
Utsab Dahal
1 - inputs are float values so cast input with float
2 - BMI formula is wrong. it should be weight/(height**2)
3 - conditions are wrong
4 - 1st characters are in caps of each output
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")
+ 4
The input() function results in strings.
To get integers via input, you have to use the int() function, e.g.
height = int(input())
If you want to input floats (i.e. fractions), use float(input()).
By the way, the parentheses around height in line 3 are not necessary.
Last, isn't the formula weight / height**2 ?
+ 4
đ
°đ
č đ
đ
đ
đ
đ
Ł here the parentheses aren't needed either because ** is evaluated before / đ
+ 4
David Ashton
Yes you are right sir but will not affect on result.
0
Utsab Dahal
Maybe network issue just keep trying. It will work.