- 1
What is the code to the project of bmi calculator in python 3?
I hv tried multiple times but error occurs everytime
23 Respostas
+ 13
weight = float(input("85"))
height = float(input("1.9"))
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")
else:
print("Obesity")
+ 4
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")
else :
print ("Obesity")
+ 3
weight = float(input("85"))
height = float(input("1.9"))
BMI = weight/(height**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")
See i hv posted the code now.Can u help where i am going wrong?
+ 1
Ohk..thanks! I will remember that next time
+ 1
Just change to
weight = float(input())
height = float(input())
As explained by Slick
+ 1
Here we go
weight = float(input("85"))
height = float(input("1.9"))
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")
else:
print("Obesity")
0
I don't want the exact answer.i just want to check where i am going wrong
0
I don't know how sl calculates bmi, so if its a problem with the math, that's on you.
BUT, when checking a single value against multiple values in a single if/elif statement use the value to compare both times:
BAD:
...
elif BMI >= 25 and < 30:
...
GOOD:
...
elif (BMI >= 25) and (BMI < 30):
...
See how the "GOOD" one has the variable in it twice? That's needed if you want to compare it against multiple values
0
Still not workingš¶
0
post. the. code
0
what is float(input("85")) for???
float() turns stuff into floats
input() takes user input thats typed AFTER the program starts
when a string is included in input(), for example: choice = input("Enter a choice: ")
that string is a prompt, not anything to do w/ the variable. You may need to go over input/output again
0
Got it, thanks slick and Aditya!
0
weight=float(input())
height=float(input())
bmi=weight/(height**2)
if bmi<18.5:
print("Underweight")
if bmi>=18.5 and bmi<25:
print("Normal")
if bmi>=25 and bmi<30:
print("Overweight")
if bmi>=30:
print("Obesity")
This was my answer then....try check it out
0
Try this:
w = int(input())
h = float(input())
bmi = w / (h*h)
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")
0
Thank you that helped so much
0
I solved mine using on if statement no elif or else
0
Hello, I wanted to ask if someone can explain to me why my code gave me an error?
I tried it in the terminal and it worked perfectly.
but here in sololearn it didn't work.
so I had to remove the string from the inputs so it could work in sololearn.
FIRST CODE (THAT DOES NOT WORK IN SOLOLEARN BUT IT WORKS IN THE TERMINAL):
w = float(input("Weight"))
h = float(input("Height"))
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")
SECOND CODE (WHAT IF IT WORKS IN SOLOLEARN AND ALSO IN THE TERMINAL):
w = float(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")
0
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')
0
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")
else:
print("Obesity")
Could someone please point out my error? And correct me
.... waiting
0
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')
else:
print ('Obesity')
**********************************
This is the code I used, I hope it helps