BMI calculator in #python

Following a conversation with a student today, here is my version of a simple Python 3 script for calculating your body mass index index.



print("BMI Calculator")

while True:
    mass = float(input("\n\nEnter mass (kg): "))
    height = float(input("Enter height (m): "))
    bmi = mass / (height**2)
    underweight = 18.5 * (height**2)
    normal = 25 * (height**2)
    borderline = 30 * (height**2)
    
    print("Your bmi is : ", "%.1f" % bmi)

    if (bmi <= 18.5):
        print("'Underweight.'")
        print("To be 'normal' weight, your mass would need to be : ", "%.1f" % underweight, "-", "%.1f" % normal, "kg" )
        print("You are advised to gain ", "%.1f" % (mass - underweight), "kg") 
    elif (bmi < 25):
        print("Normal weight.")
    elif (bmi <30):
        print("Borderline high.")
        print("To be 'normal' weight, your mass would need to be : ", "%.1f" % underweight, "-", "%.1f" % normal, "kg" )
        print("You are advised to lose ", "%.1f" % (mass - normal), "kg")
    else:
        print("High")
        print("To be 'normal' weight, your mass would to be : ", "%.1f" % underweight, "-", "%.1f" % normal, "kg" )
        print("You are advised to lose ", "%.1f" % (mass - normal), "kg")
        print("To be 'borderline high', your mass would need to be : ", "%.1f" % borderline, "-", "%.1f" % normal, "kg" )
        print("You are advised to lose ", "%.1f" % (mass - borderline), "kg")
        
    
    
    

1 comments:

Body mass index was always designed to become considered a general guide for caregivers. However, doctors must take into account other factors over a long-term basis. For instance, muscular building, bone density, and cultural origin can skew the results of an BMI Calculator. It is very frequent to consider that the BMI Calculator in the health care finance of personal health insurance plan. Providers will make use of a top BMI as a chalk stage to increase insurance rates or refuse policy. Furthermore, the BMI is often employed by surgeons to decide on whether someone participates that the Gastric Band procedure. Here are BMI Calculator through which you can calculate your body mass index, body fat percentage although waist to height ratio,instantly.