+ 8
Help in BMI CALCULATOR
My code weight = w height = h w = int(input()) h = int(input()) r = (w / h**2) if(r <18.5): print:('Underweight') else : if(r >=18.5): if(r < 25): print:('Normal') else : if(r >=25): if(r <30): print:('Overweight') else : if(r >30): print:('Obesity')
30 odpowiedzi
+ 2
Your code...
weight = w
height = h
#above makes no sense as w and h are not created yet
w = int(input())
h = int(input()) #change both int to float
r = (w / h**2) #brackets only needed around h**2 so its calculated first
if(r <18.5): #brackets not needed after if statement
print:('Underweight')
else : #this line does nothing
if(r >=18.5):
if(r < 25):
print:('Normal') #colon only needed at end of if condition line not after print see below how you can use elif... else is a last condition if no conditions are met but not needed for this as any number will output a result from print anyway
#Code below working after editing your code
#weight = w
#height = h
w = float (input())
h = float (input())
r = w / (h**2)
if r <18.5:
print('Underweight')
elif r >=18.5 and r < 25:
print('Normal')
elif r >=25 and r <30:
print('Overweight')
elif r >30:
print('Obesity')
+ 6
weight = int(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")
elif BMI >= 30:
print("Obesity")
Try this method
+ 5
I didnt get r in mine i just done the simplest way the question asked i guess idk if that code works u can just try it my code is
weight = float(input())
height = float(input())
if weight / height**2 < 18.5:
print("Underweight")
elif weight / height**2 < 25:
print("Normal")
elif weight / height**2 < 30:
print("Overweight")
elif weight / height**2 >= 30:
print("Obesity")
+ 3
w = int(input('tape your weigth: '))
h = int(input('tape your height: '))
r = (w/((h**2)/10000))
if r < 18.5:
print('Underweight')
else:
if r >=18.5:
if r < 25:
print('Normal')
else:
if r >= 25:
if r < 30:
print('Overweigth')
else:
if r > 30:
print('Obesity')
+ 3
def lol():
w = int(input("weight: "))
h = int(input("height: "))
r = ((w/h)**2)
if r > 30:
return "obesity"
if r > 25:
return "overweight"
if r > 18.5:
return "normal"
if r < 18.5:
return "underweight"
print(lol())
This is the easiest way as I know...
+ 2
Cleiton Trader i need your help your code didn't work
+ 1
w = int(input('tape your weigth: '))
h = int(input('tape your height: '))
r = (w/((h**2)/10000))
if r < 18.5:
print('Underweight')
else:
if r >=18.5:
if r < 25:
print('Normal')
else:
if r >= 25:
if r < 30:
print('Overweigth')
else:
if r > 30:
print('Obesity')
+ 1
Dont turn the heights input into a integer make it a float and then its ez
+ 1
What about this code Rxkas .0000 mariana carneiro mendes
w = int(input('tape your weigth: '))
h = int(input('tape your height: '))
r = (w/((h**2)/10000))
if r < 18.5:
print('Underweight')
else:
if r >=18.5:
if r < 25:
print('Normal')
else:
if r >= 25:
if r < 30:
print('Overweigth')
else:
if r > 30:
print('Obesity')
+ 1
This might be easier to understand:
weight=float(input())
height=float(input())
if((weight/height**2)<18.5):
print("Underweight")
elif ((weight/height**2)>=18.5) and((weight/height**2)<25):
print ("Normal")
elif((weight/height**2)>=25) and ((weight/height**2)<30):
print("Overweight")
elif((weight/height**2)>=30):
print("Obesity")
+ 1
Read Rxkas .0000 and Senthil Kumaran answers. They point you to the right direction.
Besides, think again about the comparisons using "greater than". Given the comparisons right before each one, are they really needed?
0
Maybe you can use these for inspiration:
https://code.sololearn.com/W5xBZ1vwT1g4/#
https://code.sololearn.com/clcIdgrl1ffZ/#c
Python is not a strong suit of mine, I dont think though that print needs the colon char after it
ie
print:('Underweight')
instead
print('Underweight')
Also someone python smart needs to jump in I'm not sure about your integer math, in other languages the decimals are truncated.
0
Eu não consegui compilar o código, ele contem alguns erros inclusive na linha 7 (print:('Underweight')) tem : que nao precisa no print:
0
Do you have discord ?
0
No
0
What is you questions?
0
Can you give me the solution of this task
0
At pydroid 3 the code ran
But at sololearn he didin't work
0
What i do to write privite msg
0
The results are underweight ?