BMI Calculator - Python
Beginner Project
This project introduces a BMI Calculator, a foundational Python
application designed to illustrate core programming principles. The
Body Mass Index (BMI) is a metric used to assess whether an
individual's weight is healthy in relation to their height.
What the Program Does
1
Gets User Input
Collects name, weight, and height from the user.
Calculates BMI
Uses the formula: BMI = weight (kg) ÷ height² (m).
Categorizes Result
Classifies BMI as Underweight, Normal, Overweight, or Obese.
Displays Results
Presents the BMI and category with personalized advice.
Python Concepts Used
Variables 📦 Data Types 🔢
String: Text (names, messages)
name = "John" # Stores textweight = 70.5 # Stores decimalheight = 1.75 #
Float: Decimal numbers (70.5, 1.75)
Stores decimal
Int: Whole numbers (25, 100)
Input/Output 💬
input() # Gets data FROM userprint() # Shows data TO user
The Logic Flow
START
Get Input
Calculate
Check Category
Display
END
Conditional Statements 🚦
The program uses if-
if bmi < 18.5: category =
elif-else to make
"Underweight"elif bmi < 25:
decisions. It checks
category = "Normal
the BMI value and
Weight"elif bmi < 30:
assigns the
category = "Overweight"else:
appropriate
category = "Obese"
category, just like a
doctor would.
Complexity Analysis: O(1) -
Constant Time & Space
Constant Time
Program runs in the same time regardless of input size. No loops, just simple
calculations.
Constant Space
Uses a fixed amount of memory (only 7 variables). Efficient for any number of users.
This is the most efficient algorithm possible - O(1). It's like having a calculator
that always takes the same time to give an answer.
Why O(1) is Important
Big-O Comparison: Real-World Impact:
O(1) - Constant ⚡ ← Our • Instagram BMI feature? →
program (FASTEST!) Handles millions instantly!
O(log n) - Logarithmic 🚀 • Hospital app? → No waiting
O(n) - Linear 🚶 time!
• Fitness tracker? → Instant
O(n²) - Quadratic 🐢
feedback!
Code Demonstration
Enter your name? JohnEnter your weight in kg: 70Enter
your height in meters: 1.75YOUR BMI: 22.86CATEGORY:
Normal Weight
What We Learned 🎓
1 Basic Python Syntax
Variables, input/output operations.
2 Mathematical Operations
Division, multiplication, and formula application.
3 Conditional Logic
Making decisions with if-elif-else statements.
4 Algorithm Efficiency
Understanding time and space complexity (O(1)).
5 User Experience
Clean output formatting for better readability.
Possible Improvements 🚀
Add Imperial Units
Support for pounds and inches.
Create Visual Graph
Visualize BMI trends over time.
Save History
Store past BMI measurements.
Set Weight Goals
Track progress towards fitness objectives.
Age/Gender-Specific Advice
Personalized health recommendations.