Day 34 of 100 Days Coding Challenge: Python
I built my first Flask BMI calculator back on Day 7—just me, Python, and a simple formula. It worked well for metric units, crunchiDay 34 – BMI: Bridging the Gap Between Kilograms and Inchesng the numbers in centimeters and kilograms without complaint. But today, I decided to revisit it with a friendlier approach: one that welcomes both metric and imperial users. After all, some people think in kilos, others think in pounds—and both deserve an app that meets them where they are. So, I gave it a new home in Flask and added support for both systems. A small upgrade, but a meaningful one.
Today’s Motivation / Challenge
BMI calculators are a classic beginner’s project. They’re easy to understand, quick to build, and surprisingly useful. But for me, this wasn’t just about calculating numbers—it was about building a more thoughtful, inclusive tool. Rewriting it in Flask gave me a chance to sharpen my web development skills while creating something a little more flexible and user-friendly.
Purpose of the Code (Object)
This code creates a simple web app that calculates your Body Mass Index (BMI) based on your height and weight. You can choose between metric or imperial units, and the app will give you your BMI along with a general category, like “Normal” or “Overweight.” No fuss, just quick feedback.
AI Prompt:
“Create a Flask web app that calculates BMI from user input. Include support for both metric and imperial units, and display the result with a category like ‘Normal’ or ‘Overweight’.”
Functions & Features
- Lets users select metric (kg/cm) or imperial (lb/ft+in)
- Accepts user input for height and weight
- Calculates BMI using the appropriate formula
- Categorizes results (e.g., Underweight, Normal, Overweight, Obese)
Requirements / Setup
- pip install flask
Minimal Code Sample
if unit == “imperial”:
total_inches = float(ft) * 12 + float(inch)
bmi = round((float(weight_lb) / (total_inches ** 2)) * 703, 2)
else:
height_m = float(height_cm) / 100
bmi = round(float(weight_kg) / (height_m ** 2), 2)
// Calculates BMI based on the selected unit system.
*** I am very sorry, I realized I forgot to add to GitHub. I uploaded later. ***
Notes / Lessons Learned
When I first started working with Flask, things got messy fast. Each new app ended up in its own makeshift folder, and before long, I discovered that Flask can be downright fussy about file locations—especially when it comes to templates. That lesson pushed me to get organized. Now, every project gets its own environment, a dedicated folder, and a clearly named app file (I’ve officially retired the one-size-fits-all “app.py”). I also learned to run multiple apps on different ports, which made testing far less chaotic. A bit of structure early on, it turns out, saves a world of confusion later.
Optional Ideas for Expansion
- Add JavaScript to display BMI results instantly without reloading
- Store BMI history so users can track changes over time
- Include wellness tips based on BMI results

