PYTHON: How to calculate BMI by If statement

Spread the love

1. What is the BMI?

The BMI is the abbreviation of the Body Mass Index (BMI). It can be used to measure leanness based on height and weight. It is also a measurement of the health condition. It is used for the statistical purposes, it analyzes the health condition of a person’s weight on people of different heights.

2. Formula and standard

BMI=Weight(Kilogram) ÷ (height)^2 (m)

For an adult:

  • Too light: Below 18.5
  • Normal: 18.5-23.9
  • Overweight: 24-27
  • Obesity: 28-32
  • Very Obese: above 32

3. Source code

height=float(input('What is your height(m): '))
weight=float(input('What is your weight(kg): '))
if BMI<18.5:
  print('Too Light')
elif 18.5<=BMI<25:
elif 25<=BMI<28:
elif 28<=BMI<32:
elif BMI>=32:
       print('Seriously Overweight')
print('your BMI is :',BMI)

4. Output

5. Note

The key concept behind this code:

  • To understand how to use input
  • To undersantd how to convert data type
  • To understand how to make condition judgement by if and elif
If you want to know more about me, please get on the about page. :)
Posts created 18

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
error: Content is protected !!