DAY 06 — 60 DAY PYTHON CHALLENGE
💻 BMI Calculator
Python में BMI Calculator — Body Mass Index हिंदी में
Advertisement
Complete Code
python — day06.py
def bmi_calculator(): print("⚖️ BMI Calculator") print("BMI = weight(kg) ÷ height²(m)") print("-" * 32) try: weight = float(input("वजन (kg): ")) height = float(input("उँचाई (cm): ")) h_m = height / 100 bmi = weight / (h_m ** 2) print(f"\n📊 BMI: {bmi:.1f}") print("-" * 32) if bmi < 18.5: cat, tip = "🔵 Underweight", "ज्यादा खाएं" elif bmi < 25.0: cat, tip = "🟢 Normal ✅", "बढ़िया है!" elif bmi < 30.0: cat, tip = "🟡 Overweight", "थोड़ा exercise" else: cat, tip = "🔴 Obese", "doctor से मिलें" print(f"Category: {cat}") print(f"Tip: {tip}") except ValueError: print("❌ सही number डालें!") bmi_calculator()
OUTPUT
⚖️ BMI Calculator
वजन (kg): 70
उँचाई (cm): 175
📊 BMI: 22.9
────────────────────────────────
Category: 🟢 Normal ✅
Tip: बढ़िया है!
यह Code कैसे काम करता है?
BMI = weight / height² — cm को m में बदलना जरूरी है (÷100)। **2 से square होता है। Tuple unpacking से एक ही line में cat और tip assign होते हैं।
Advertisement