Home - grupoprogramacao2019/BMI GitHub Wiki

BMI calculator is able to return 5 types of ratings: Too underweight, Underweight, Weight within normal, Overweight, Too overweight.

  • Full code
heightFloat = 1.74
WeightFloat = 64.0
BMI = WeightFloat/(heightFloat**2)

print(BMI)

print("Too underweight?", BMI < 17.0)
print("Underweight?", BMI >= 17.0 and BMI <= 18.5)
print("Weight within normal?", BMI > 18.5 and BMI <= 25.0)
print("Overweight?", BMI > 25.0 and BMI <= 30.0)
print("Too overweight?", BMI > 30.0)

*There are two input variables so that the BMI calculation can be performed by the program.

heightFloat = 1.74
WeightFloat = 64.0
BMI = WeightFloat/(heightFloat**2)

NOTE: To test the calculator just change the values โ€‹โ€‹of the heightFloat and WeightFloat variables, and recompile the code.

*After recompiling the program we will have a result printed by True / False for the five outputs implemented.

print("Too underweight?", BMI < 17.0)
print("Underweight?", BMI >= 17.0 and BMI <= 18.5)
print("Weight within normal?", BMI > 18.5 and BMI <= 25.0)
print("Overweight?", BMI > 25.0 and BMI <= 30.0)
print("Too overweight?", BMI > 30.0)