# A simple BMI calculator script using python3!

22 May 2018views: 268 • #### Share:

The Body Mass Index(BMI) is a value used to categorize a person as underweight, normal weight, overweight. Common accepted BMI ranges are underweight: below 18.5, normal: between 18.5 to 25 and overweight: above 25. The BMI is defined as body mass in Kg divided by height in meter square. So BMI = (Kg/m2).

A computer programm can easily be written to find the BMI of a person. The programm should take two input one is the person weight in Kg and another the person height in meter.

Below is the simple python3 code to do the task. It takes two input in separate lines, first being persons weight and second is persons height. Next it calculates the BMI using the formula (weight/height2) and stores it in the variable BMI. Next step is to categorize the person as underweight, normal, overweight. Here we can just use the `if` statement to first check if the BMI is below 18.5 then output underweight. If its not below 18.5 then move on to the next statement and use the `elif` statement to check if its greather than 25 then output overweight. If its not greather than 25 then move to the `else` block and just output normal because if the BMI is not less than 15.5 and also not greather than 25 than it must lie in between 18.5 and 25.

On the last line the person BMI is also displayed using format to make it only 2 significent figure after the desimal point. To run the programm save the file as BMI.py and open a commant window or terminal on windows open the folder containing the file and press shift + right click and choose open a command window here next type `python BMI.py` to run the programm on the terminal or window. There are other options to do the task this is the most basic, clean and beginners friendly to learn the basic. The programm can be expanded by providing users more control over weight and height convertions.

Thank you for Subscribing! We will make sure you never miss a thing.  Name is ok.
Comment is ok.
Email is ok.
Website is ok.

#### RELATED POSTS:          ### MOST VIEWED:          