+ 4
My output is (Underweight) with space under it. .... Expected output (Underweight) without space 😑 help me in that project
55 Respuestas
0
https://code.sololearn.com/c0ZgTf0yT1u0/?ref=app
+ 6
That means your code is correct. Don't worry about the space – it's not related to your code
+ 5
Nothing to fix, it's just how sololearn displays it. It doesn't have anything to do with your code.
So which test case shows an error?
+ 3
Hayam Mohammed
Try this:
weight=int(input())
height=float(input())
BMI=weight/(height**2)
if BMI<18.5:
print("Underweight")
elif 18.5>=BMI and BMI< 25:
print('Normal')
elif 25<= BMI and BMI<30:
print("Overweight")
else:
print('Obesity')
You are getting an error because you didn't use the and operator for Normal and Overweight.
The and operator is important for this type of code. I hope you understand.
+ 2
your Bmi calculation formula is wrong,
bmi formula is :- weight(kg)/height(m)^2
so BMI = weight / (height/100)**2;
https://code.sololearn.com/cpfjqSZMgu4v/?ref=app
+ 2
What did you input?
Weight is in kg
Height in m
+ 2
But it shows green (passed)?
The space below could just be the field size and not due to your code?
+ 2
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')
Try using this one
+ 2
Finally guys i've passed the project
Thanks to **🇦🇪|🇦🇪**
+ 1
We cant use the link in a tag. Just put it in the description
+ 1
Sorry,
it's my first question
+ 1
Note that you have a typo in overweight
+ 1
Andy_Roid thanks for help
But your formula gives me the output (obesity) while the expected output is Underweight
+ 1
The project height input is in meters so i think the formula is right
+ 1
Hayam Mohammed Go through the link u'll figure it out.
+ 1
Hayam Mohammed when calculating height in meters, and weight in Kilograms
+ 1
Hayam Mohammed Input height in cm's and weight in kilograms,
but when calculating height in mtrs and weight in kgs
+ 1
So does it work now?
+ 1
Your code seems to work as expected. Which test case fails?