0

I tried a lot but i couldn't complete the BMI calculator code. Please help. How can I solve it?

https://code.sololearn.com/cKBK5AovGcGg/?ref=app

20th May 2021, 7:55 AM
Utsab Dahal
Utsab Dahal - avatar
7 Antworten
+ 5
Problem solved. David Ashton sir and 🅰🅹 🅐🅝🅐🅝🅣 sir thanks for your help. It worked. Thanks alot.
20th May 2021, 8:40 AM
Utsab Dahal
Utsab Dahal - avatar
+ 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")
20th May 2021, 8:36 AM
David Ashton
David Ashton - avatar
+ 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")
20th May 2021, 8:19 AM
A͢J
A͢J - avatar
+ 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 ?
20th May 2021, 8:16 AM
David Ashton
David Ashton - avatar
+ 4
🅰🅹 🅐🅝🅐🅝🅣 here the parentheses aren't needed either because ** is evaluated before / 🙂
20th May 2021, 8:21 AM
David Ashton
David Ashton - avatar
+ 4
David Ashton Yes you are right sir but will not affect on result.
20th May 2021, 8:22 AM
A͢J
A͢J - avatar
0
Utsab Dahal Maybe network issue just keep trying. It will work.
20th May 2021, 8:36 AM
A͢J
A͢J - avatar