Contact Us:

670 Lafayette Ave, Brooklyn,
NY 11216

+1 800 966 4564
+1 800 9667 4558

BMI Calculator in Python

Write a program that interprets the Body Mass Index (BMI) based on a user’s weight and height.

It should tell them the interpretation of their BMI based on the BMI value.

  • Under 18.5 they are underweight
  • Over 18.5 but below 25 they have a normal weight
  • Over 25 but below 30 they are slightly overweight
  • Over 30 but below 35 they are obese
  • Above 35 they are clinically obese.
print("Welcome to BMI calculator!")
bmi_cal = 0
comment = None
weight = float(input("Enter your height:\n"))
height = float(input("Enter your weight:\n"))
if (weight != 0 and height != 0):
  
  bmi_cal = round(weight / (height ** 2), 2)
  if (bmi_cal <= 18.5):
    comment = "underweight"
  elif (bmi_cal > 18.5 and bmi_cal <= 22):
    comment = "normal weight"
  elif (bmi_cal > 23 and bmi_cal <= 28):
    comment = "slightly overweight"
  elif (bmi_cal > 29 and bmi_cal <= 33):
    comment = "obese"
  elif (bmi_cal > 34 and bmi_cal <= 40):
    comment = "clinically obese"
else:
  print("Height & Weight Can't be 0 to get BMI result!")
if comment != None:
  print(f"Your BMI is {bmi_cal}, you are {comment}.")
else:
  print(f"Opps! Your BMI is {bmi_cal}.")
0 0 votes
Article Rating

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x