+ 1

BMI project

height = float(1.85) weight = float(52) result = (weight / height**2) if result < 18.5: print("Underweight") if 18.5 <= result <25: print("Normal") if 25 <= result <30: print("Overweight") if result > 30: print("Obesity") Is there anything wrong? I can t pass it

29th Sep 2022, 11:41 AM
Demi
Demi - avatar
9 Answers
+ 3
Hi! Don't hard code variables "weight" and "height". This is input data. And it will be variables five times
29th Sep 2022, 12:39 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 3
Demi, Rewrite it as, Result=(weight/height*height) And get height and weight as user input as, Weight=float(input) Height=float(input) Try this it works...
30th Sep 2022, 6:06 AM
Arun Venkatesh
Arun Venkatesh - avatar
+ 2
float(input) --->>> float(input())
30th Sep 2022, 6:28 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Yeah I didn't noticed...
30th Sep 2022, 10:54 AM
Arun Venkatesh
Arun Venkatesh - avatar
+ 2
I run the code...it has no errors
30th Sep 2022, 11:01 AM
Arun Venkatesh
Arun Venkatesh - avatar
+ 1
then I also made a little mistake in my mind
30th Sep 2022, 11:46 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
w=int(input()) h=float(input()) BMI=(w/h**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") take w as int(input()), it is the thing I missed, it will work
1st Oct 2022, 6:07 AM
Arun Venkatesh
Arun Venkatesh - avatar
0
all the same, the program will still not work, since not all errors have been found yet
30th Sep 2022, 10:58 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
I’m also having this exact issue. Did either of you have luck fixing it? https://www.mycfavisit.biz/
1st Oct 2022, 5:31 AM
Atnip5874