0
I made a BMI Calculator in Python and youa are supposed to write the height in meter. I want whenever you write the height in ce
weight = int(input()) height = float(input()) BMI = weight / height ** 2 if BMI < 18.5: print("Underweight") else: if 25 > BMI >= 18.5: print("Normal") else: if 30 > BMI >= 25: print("Overweight") else: if BMI >= 30: print("Obesity") print("You\'re BMI is " + str(BMI))
3 Respuestas
+ 1
Please show us your attempt so far so we may help. Thanks.
Hint:
>> To get the input of weight and height:
weight = float(input())
height = float(input())
>> To compute the BMI
bmi = weight/height ** 2
EDIT:
Seems like you now have your attempts, thanks.
Your control flow is working, it is just the comparison that needs to be fixed.
For example:
Instead of (25 > BMI >= 18) it should be (BMI >= 18 and BMI < 25)
https://code.sololearn.com/c95j6wulF4gZ/?ref=app
Additional, there is a keyword called 'elif' which is short for 'else if'. Here's an example which is similar to your code using 'elif'.
https://code.sololearn.com/cRyIo348sEd0/?ref=app
If you need more questions please feel feee to ask. Thanks.
0
For an input in cm you should multiply the cm with 0.01, turning them into meter for the BMW-Formular. If that was your question.
0
Hi. Use Elif instead of Else, also you must check the indentation.
if BMI < ___:
print ("")
elif BMI ...
print ("")
And so on.