Body mass index is a value derived from the mass and height of a person. The formula is BMI = kg/m2 where kg is a person’s weight in kilograms and m2 is their height in metres squared.

Example:


Weight = 68 kg, Height = 165 cm (1.65 m)

Calculation: 68 ÷ (1.65 x 1.65) = 24.98

BMI = 24.98


Program:


# Write your height in meters

height = float(input("Enter your height : "))
print(height)

# Write your weight in kilograms
weight = float(input("Enter your weight : "))
print(weight)

#Algorithm
tem=height/100
bmi = round(weight / (tem * tem) , 2)

print("")
print("Your body mass index is : ", bmi)
print("")
if(bmi < 18.5):
    print("You are under weight")

if(bmi > 18.5 and bmi <= 24.99):
    print("You have a normal weight")

if(bmi >= 25 and bmi <= 29.99):
    print("You are over weight")

if(bmi >= 30 and bmi <= 34.99):
    print("You are obese (class I)")

if(bmi >= 35 and bmi <= 39.99):
    print("You are obese (class II)")

if(bmi >= 40):
    print("You are obese (class III)")

OUTPUT:



Post a Comment

Previous Post Next Post