+ 1
Bmi calculator - Hello, guys. How can i solve this problem? My code isn't matching.
bmi = float(input()/float(input())**2 if bmi <18.5 : print('Underweight.') elif bmi >=18.5 and <25 : print('Normal.') elif bmi >=25 and <30 : print('Overweight.') else : print('Obesity.')
9 Answers
+ 3
Not really.
The test case just expects your output without any other punctuation marks.
E.g "Underweight" and not "Underweight."
They are different outputs
+ 1
#try this
weight = float(input())
height = float(input())
bmi = weight / height**2
if bmi < 18.5: print("Underweight")
elif 18.5 <= bmi < 25: print("Normal")
elif 25 < bmi < 30: print("Overweight")
else: print("Obesity")
+ 1
Emeh Matthew Man, i want to thank you. I stopped this course months ago because i couldn't solve this and now tou save me. đ±
+ 1
Helping each other is how we learn better đ€
+ 1
I think we applied the same logic.
You just made some errors like:
- Including a period (.) in your print statements
- Your elif conditions were wrongly written. bmi >= 18.5 and < 25 is invalid syntax. Instead say bmi >= 18.5 and bmi < 25 or more compactly 18.5 <= bmi < 25.
Asides these, your logic is correct
0
Changes
bmi = float(input()) / float(input())**2
elif 18.5 <= bmi < 25: print("Normal")
elif 25 <= bmi < 30:print("Overweight")
0
Emeh Matthew i get invalid syntax here
0
Emeh Matthew I agree. How you solve this?
0
Emeh Matthew So this dot (.) refers to somenthing? Lol. It's more hard than i tought. Thanks, man.