BMI Calculator with Category
Calculate BMI and categorize.
IntermediatePhase 6 - Category 5: Real-World Logic ProblemsExample 3 of 15
bmi-calculator-with-category.py
1# Take inputs2weight = float(input("Enter weight (kg): "))3height = float(input("Enter height (m): "))45# Calculate BMI6bmi = weight / (height ** 2)78# Categorize9if bmi < 18.5:10 category = "Underweight"11elif bmi < 25:12 category = "Normal"13elif bmi < 30:14 category = "Overweight"15else:16 category = "Obese"1718print(f"BMI: {bmi:.2f}")19print(f"Category: {category}")
Output
Enter weight (kg): 70 Enter height (m): 1.75 BMI: 22.86 Category: Normal
What's going on
Calculate BMI and assign category.
Key Concepts:
BMI = weight / height²
Check ranges for categories
Use elif chain
🔗Related Content
- 📖
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- 📝
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- 💻
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum