Q:

BMI (Body Mass Index) calculator in Python

0

Given weight and height of a person and we have to find the BMI (Body Mass Index) using Python.

Example:

    Input:
    Height = 1.75
    Weigth = 64

    Output:
    BMI is: 20.89 and you are: Healthy

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to calculate BMI in Python

# getting input from the user and assigning it to user

height = float(input("Enter height in meters: "))
weight = float(input("Enter weight in kg: "))

# the formula for calculating bmi

bmi = weight/(height**2) 
# ** is the power of operator i.e height*height in this case

print("Your BMI is: {0} and you are: ".format(bmi), end='')

#conditions
if ( bmi < 16):
   print("severely underweight")

elif ( bmi >= 16 and bmi < 18.5):
   print("underweight")

elif ( bmi >= 18.5 and bmi < 25):
   print("Healthy")

elif ( bmi >= 25 and bmi < 30):
   print("overweight")

elif ( bmi >=30):
   print("severely overweight")

Output

Python program for BMI Calculator

If you liked the article or have any doubt, please write in the comment box.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now