DEV Community

Cover image for BMI Calculator
Scott Gordon
Scott Gordon

Posted on

3 1

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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay