how to make bmi calculator in python code example

Example 1: how to make bmi calculator in python

weight = float(input('What is your weight? (Kg) '))
height = float(input('What is your height? (Mtr) '))
bmi = weight/(height*height)

if bmi <= 18.5:
    print('Your BMI is', bmi, 'which means you are underweight')

elif 18.5 < bmi < 25:
    print('Your BMI is', bmi,'which means you are normal')

elif 25 < bmi < 30:
    print('your BMI is', bmi,' which means you are overweight')

elif bmi > 30:
    print('Your BMI is', bmi,'which means you are obese')

Example 2: python bmi calculator code

print("Welcome to BMI calculator, by Abthahi Tazrian.")

# Offer Measurement Conversions

Offer_Conversions = input("Would you like to convert your imperial units to metric? (yes / no): ")

if Offer_Conversions == "yes":
    Imperial_Weight = input("What is your weight in pounds?: ")
    Imperial_Height = input("What is your height in feet (decimals)?: ")

    Imperial_Weight = float(Imperial_Weight)
    Imperial_Height = float(Imperial_Height)

    Metric_Converted_Weight = Imperial_Weight * 2.205
    Metric_Converted_Height = Imperial_Height * 30.48

    Metric_Converted_Weight = str(Metric_Converted_Weight)
    Metric_Converted_Height = str(Metric_Converted_Height)

    print("Your metric weight is " + Metric_Converted_Weight + " kg, please note this for the next stage.")
    print("Your metric height is " + Metric_Converted_Height + " cm, please note this for the next stage.")
    print("--")
elif Offer_Conversions == "no":
    print("--")

# Data Collection

Age = input("Put in your age: ")
Weight = input("Put in your weight in KG: ")
Height = input("Put in your height in CM: ")

# BMI Formula Calculation

Weight = float(Weight)
Height = float(Height)

Height_Squared = Height * Height
BMI_Formula_Assisted = Weight / Height_Squared
BMI_Formula_Completed = BMI_Formula_Assisted * 10000

# Health Chart Display

BMI_Formula_Completed = str(BMI_Formula_Completed)

print("You have a BMI score of " + BMI_Formula_Completed + ".")

BMI_Formula_Completed = float(BMI_Formula_Completed)

if BMI_Formula_Completed <= 18.5:
    print("You are underweight, consider gaining weight to bring your BMI to between 20 and 25.")
elif BMI_Formula_Completed <= 25:
    print("You are perfectly healthy, with a BMI within a healthy range of between 20 and 25.")
elif BMI_Formula_Completed <= 30:
    print("You are overweight, speak to a doctor about setting yourself a new target BMI between 20 and 25.")
elif BMI_Formula_Completed >= 30.1:
    print("You are obese, you need to lower your BMI to between 20 and 25 or else you may be at risks.")