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))

7th Feb 2021, 5:54 PM
Xaniar
Xaniar - avatar
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.
7th Feb 2021, 5:55 PM
noteve
noteve - avatar
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.
7th Feb 2021, 9:11 PM
StephBill
StephBill - avatar
0
Hi. Use Elif instead of Else, also you must check the indentation. if BMI < ___: print ("") elif BMI ... print ("") And so on.
16th Apr 2021, 6:39 PM
Fabián García Gómez
Fabián García Gómez - avatar