BMI calculator in Python

This is just a simple BMI calculator coded in Python.

name = "Johnny"
height_m = 2
weight_kg = 90

bmi = weight_kg / (height_m ** 2)
print("bmi: ")
print(bmi)
if bmi < 25:
    print(name + ' is not overweight')
else:
    print(name + ' is overweight')

As a function:

name1 = "Brian"
height_m1 = 2
weight_kg1 = 90

name2 = "Brian's sister"
height_m2 = 1.8
weight_kg2 = 160

def bmi_calculator(name, height_m, weight_kg):
    bmi = weight_kg / (height_m ** 2)
    print("bmi: ")
    print(bmi)
    if bmi < 25:
        return name + " is not overweight"
    else:
        return name + " is overweight"

result1 = bmi_calculator(name1, height_m1, weight_kg1)
print(result1)

print(bmi_calculator(name2, height_m2, weight_kg2))

Comments

Popular posts from this blog

Installing Microsoft ODBC Driver to connect to SQL from Python on Mac OS X

Connection to MSSQL with Pythonan and pyodbc (on Mac OS X)

Installing PyCharm on Mac