← Back to Blog

Your Third Mini Project — Math Around You

The problem...

Math isn't just in textbooks.

It's in your body. Your weight. Your height. Your health.

And Python can calculate it in seconds.

The idea!

You're going to build a BMI calculator.

The user types their weight and height. Your program calculates their BMI and tells them what it means.

What is BMI?

BMI — Body Mass Index — is a simple formula that uses weight and height to estimate body composition.

Formula: BMI = weight (kg) / height (m)²

bmi = weight / height ** 2

What you'll use

  • input() — to get weight and height
  • float() — both values can have decimals
  • arithmetic and ** — to apply the formula
  • f-strings — to display the result cleanly

In practice

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

bmi = weight / height ** 2
print(f"Your BMI is {bmi:.1f}")

If the user types 70 and 1.75:

Output → Your BMI is 22.9

The full program

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

bmi = weight / height ** 2

print(f"Your BMI is {bmi:.1f}")

if bmi < 18.5:
    print("Underweight")
elif bmi < 25:
    print("Normal weight")
elif bmi < 30:
    print("Overweight")
else:
    print("Obese")

Wait — if and elif are new. Don't worry about the syntax yet.

Read it like plain English: if BMI is less than 18.5, print "Underweight". Otherwise check the next condition.

You'll learn this properly in the next chapter. For now, just use it.

What's really happening

You applied a real formula to real input and got a meaningful result.

And you got your first glimpse of conditional logic — something every program uses.

Heads up!

  • Height must be in meters — 1.75, not 175
  • height ** 2 is height squared — same as height × height
  • BMI is a simplified measure — it doesn't account for muscle mass or other factors
  • The if/elif/else block is a preview — you'll understand it fully soon

The mindset shift

Stop thinking: "Math is abstract."

Start thinking: "Math is everywhere — and Python brings it to life."

What you should understand now

  • Real formulas work directly in Python
  • ** is the exponentiation operator — use it for squares and powers
  • You got a first look at conditional logic — more on that soon
  • Three inputs, one formula, a meaningful result — that's a real program
[ login to bookmark ] // copied! 38 views · 2 min
// resources
Exercise bmi_calculator.py
← prev Your Second Mini Project — Make the Math Work next → Common Number Mistakes
// 0 comments
// No comments yet. Be the first.
// leave a comment

// Your comment will appear after approval.