DEV Community

Cover image for BMI Calculator
Scott Gordon
Scott Gordon

Posted on

BMI Calculator

# bmi_calc.py
#   This program calculates a person's BMI and prints a message telling
#   whether they are above, within, or below the healthy range.
# by: Scott Gordon

def main():
    print("***** Welcome to BMI Calculator***** \n")
    weight = float(input("Enter your weight in pounds: "))
    height = float(input("Enter your height in inches: "))

    def bmi_calculator(weight, height):
        """This program calculates a person's BMI and prints a message telling 
        whether they are above, within, or below the healthy range."""

        bmi = (weight * 720) / (height ** 2)

        if (bmi > 0) and (bmi < 19):
            return f"\nYour BMI is {bmi} you are below the healthy range."
        elif (bmi >= 19) and (bmi <= 25):
            return f"\nYour BMI is {bmi} you are in the healthy range."
        elif (bmi > 25):
            return f"\nYour BMI is {bmi} you are above the healthy range."
        else:
            return f"\nCheck your entries something went wrong."

    print(bmi_calculator(weight, height))


if __name__ == '__main__':
    main()

Enter fullscreen mode Exit fullscreen mode

Photo by NeONBRAND on Unsplash

Top comments (0)