Python Programming Examples Tutorial Index

Python Number Programs

This Python program calculates Body Mass Index (BMI); it uses a simple formula to measure the amount of body fat based on a person's weight and height.

Python Program to Calculate BMI


This Python program asks for user inputs, validates them, and performs simple calculations via a formula to obtain the BMI index.

while True:
        # Taking user input
        Height = float(input("Please enter your height in inches: "))
        Weight = float(input("Please enter your weight in pound: "))
    except ValueError:
        # Validation error.
        print("Please provide valid input.")
        continue  # Return to the start of the loop.
        if Height <= 0 or Weight <= 0:
            print("Your input must not be zero or less.")
            # Calculate BMI
            BMIIndex = round(Weight / (Height * Height) * 703, 2)

            # Print the output
            print("Your Body Mass Index is: ", BMIIndex)

            if BMIIndex < 18.5:
            elif BMIIndex <= 24.9:
            elif BMIIndex <= 29.9:


Please enter your height in inches: 72
Please enter your weight in pound: 181
Your Body Mass Index is:  24.55

What Is Body Mass Index (BMI)

Body mass index is called BMI, which measures the amount of body fat based on a person's weight and height. As per the WHO (World Health Organization), The standard BMI value is 18.5 to 24.9; If BMI falls in this range, a person's body height and weight ratio are considered healthy. A BMI less than 18.5 indicates a very skinny and underweight person who needs to increase their calorie and carbohydrate content. A BMI greater than 25 to 29.9 indicates that the person is overweight. A BMI above the range of 30 is considered very dangerous. And such a person can be classified as obese.

BMI Formulas

This Python program uses the formula below to calculate the BMI:

BMI = [weight (pound) / height2 (inches) ]* 703


For example, a person's weight is 181 lbs, and his height is 72 inches. So let's know what his BMI is?

Height: 72 inches
Square of height: (72 * 72), m2 = 5182
Weight: 181 lbs
BMI = 181/5182*703 = 24.55
Python Syntax:
print(round(Weight/(Height*Height)* 703,2));

This BMI calculator is not clinical guidance nor a substitute for professional medical advice. Since BMI depends on weight and height, it is only an indicator of body obesity. The amount of fat in individuals with the same BMI may vary. Individuals may consider seeking advice from their healthcare providers.

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram