Coders Packet

BMI Calculator in Python

By Noolu Samyuktha

A BMI Calculator will take in the height and weight of the individual and will calculate the BMI of the person.

Body mass index (BMI) is a measure of body fat based on height and weight. Based on the BMI of the individual, it will print a statement stating the overall health of the person. Alright, so the first thing we need to do is to ask the user their height & weight. This can be easily achieved through the input() function. We will convert the input string to float so that we can perform calculations with it The formula to calculate BMI is the weight (kg)/{height (m)}^2. Let's implement this formula in python.

  • If BMI is less than or equal to 16 then "you are Severely underweight" is printed
  • If BMI is less than or equal to 18.5 then "you are Underweight" is printed
  • If BMI is less than or equal to 25 then "you are Healthy" is printed
  • If BMI is less than or equal to 30 then "you are Overweight is printed 
  • If BMI is none of the above then "you are Severely Overweight" is printed
  • If BMI is equal to 0 then "enter valid details" is printed
Height=float(input("Enter your height in centimeters: "))
Weight=float(input("Enter your Weight in Kg: "))
Height = Height/100
BMI=Weight/(Height*Height)
print("your Body Mass Index is: ",BMI)
if(BMI>0):
  if(BMI<=16):
    print("you are SEVERELY UNDERWEIGHT")
  elif(BMI<=18.5):
    print("you are UNDERWEIGHT")
  elif(BMI<=25):
    print("you are HEALTHY")
  elif(BMI<=30):
    print("you are OVERWEIGHT")
  else: print("you are SEVERELY OVERWEIGHT")
else:("enter valid details")

These are the screenshots of the output where I have entered a few random heights and weight values and test all the cases.

Here, BMI is calculated and printed also given the status of the body as it is less than or equal to 25 then it has printed "you are Healthy".

Here, BMI is calculated and printed also given the status of the body as it is none of the above then it has printed "Severely Overweight".

Here, BMI is calculated and printed also given the status of the body as it is less than or equal to 16 then it has printed "Severely Underweight".

Thank you so much for reading! I hope you found this project useful.

 

Download project

Reviews Report

Submitted by Noolu Samyuktha (samyukthanoolu)

Download packets of source code on Coders Packet