Python BMI calculator project

The BMI(Body Mass Index) is calculated by weight and height of person.
And in this blog i will assist you with writing a program to calculate BMI using python.

What is BMI?

BMI can be considered as an alternative for management of body fat. BMI is inexpensive easy to perform method of weight class screening.

BMI calculator using Python


  • BMI is calculated by dividing individual’s weight(kg) by square of their height(meter).
  • After calculating BMI, we should inform user about their weight class,
    inform with these strings:
    if BMI is less than or equals to 16 → You are severely underweight.
    if BMI is between 16 — 18.5 → You are underweight.
    if BMI is between 18.5 — 25 → You are healthy!
    if BMI is between 25 — 30 → You are overweight.
    if BMI is more than 30 → You are severely overweight.
  • Edit response string as you wish

Here is my code:

Explaining terms:

  • we started by taking user’s weight(in kg) and height (in cms)
  • float() function is used to change datatype to float.
    we used float datatype here as weight and height may contain decimal values.
  • then we changed height from centimeter to height in meter.
  • after that we calculated BMI using formula we discussed above.
  • now we used if statement to check for valid BMI, user might provide 0 as weight and height and that is not valid.
  • later, we used if-elif-elsestatements to check for user’s weight class and informing them.

Star or fork this repo for more beginner friendly projects.

My github profile : Punit-Choudhary

So that’s it, I hope this article was helpful for you and you’ve learned something new today. Feel free to ask your valuable questions in comment section below.

Thank you for reading!
Happy Hacking!!