Calculate Your BMI with Python

Have you ever wondered what your Body Mass Index (BMI) is? BMI is a measure of body fat based on weight and height. It's a useful indicator of whether you're underweight, normal weight, overweight, or obese.

I've created a simple Python function that calculates your BMI for you. Here's how you can use it:

Copy and paste this code into your Python environment, and it will prompt you to enter your weight in kilograms and height in centimeters. It will then calculate your BMI and tell you whether you're underweight, normal weight, overweight, or obese based on the BMI ranges.

Take a moment to check your BMI and see where you fall on the scale. Remember, BMI is just one indicator of health, so consult with a healthcare professional for personalized advice.

# formula: Calculate BMI using the formula: (weight (kg) / (height (m) ^ 2)) * 100

def bmi_calc():
  weight = float(input("Enter your weight in kg: "))
  height = float(input("Enter your height in cm: "))
  bmi = round((weight/height**2)*10000, 2)
# Underweight: BMI Range: Less than 18.5 Normal weight: BMI Range: 18.5 - 24.9 Overweight: BMI Range: 25.0 - 29.9 Obese: BMI Range: 30.0 and above
 
  if bmi < 18.5:
    print(f"Your bmi is {bmi} and you are Underweight")
  elif 18.5 < bmi < 24.9:
    print(f"Your bmi is {bmi} and you are Normalweight")
  elif 25 < bmi < 29.9:
    print(f"Your bmi is {bmi} and you are Normalweight")
  else:
    print(f"Your bmi is {bmi} and you are obese")
   


# to call the BMI function
bmi_calc()


# Stay Healthy!

Comments

Popular posts from this blog

Introducing a Simple Funny Grading System Program in Python

From Operations to Tech: My Journey into Learning in Public

Colorful QR Code in python