BMI Calculator with Diet Suggestion Python

BMI Calculator with Diet Suggestion thumbnail

BMI Calculator with Diet Suggestion Python Project)

In today’s digital health era, combining fitness awareness with technology is one of the best ways to create high-traffic content. A BMI (Body Mass Index) Calculator with Diet Suggestions is a simple yet powerful tool that helps users understand their health status instantly.

📊 What is BMI?

BMI (Body Mass Index) is a value derived from a person’s height and weight. It helps categorize individuals into health groups such as underweight, normal, overweight, or obese.

📌 BMI Formula

BMI = Weight (kg) / Height (m)2

🧠 BMI Categories

BMI Range Category
Below 18.5Underweight
18.5 – 24.9Normal
25 – 29.9Overweight
30+Obese

🥗 Diet Suggestions Based on BMI

🟢 Underweight

  • Increase calorie intake
  • Eat foods like rice, bananas, nuts, milk
  • Include protein-rich diet (eggs, pulses)

🟡 Normal Weight

  • Maintain balanced diet
  • Include fruits, vegetables, whole grains
  • Stay active daily

🟠 Overweight

  • Reduce sugar & fried foods
  • Increase fiber intake
  • Drink more water

🔴 Obese

  • Follow low-calorie diet
  • Avoid processed foods
  • Exercise regularly

💻 Python GUI BMI Calculator (Tkinter)

🔧 Requirements


pip install tk

🧾 Complete Source Code


import tkinter as tk
from tkinter import messagebox

def calculate_bmi():
    try:
        weight = float(weight_entry.get())
        height = float(height_entry.get()) / 100
        
        bmi = weight / (height ** 2)
        bmi_result.set(f"BMI: {bmi:.2f}")
        
        if bmi < 18.5:
            category.set("Underweight")
            diet.set("Eat more calories: milk, nuts, rice, protein foods.")
        
        elif 18.5 <= bmi < 24.9:
            category.set("Normal")
            diet.set("Maintain balanced diet: fruits, veggies, grains.")
        
        elif 25 <= bmi < 29.9:
            category.set("Overweight")
            diet.set("Reduce sugar, eat fiber-rich foods, drink water.")
        
        else:
            category.set("Obese")
            diet.set("Low-calorie diet, avoid junk food, exercise daily.")
    
    except:
        messagebox.showerror("Error", "Please enter valid values")

root = tk.Tk()
root.title("BMI Calculator with Diet Suggestion")
root.geometry("400x400")

bmi_result = tk.StringVar()
category = tk.StringVar()
diet = tk.StringVar()

tk.Label(root, text="BMI Calculator", font=("Arial", 18)).pack(pady=10)

tk.Label(root, text="Weight (kg)").pack()
weight_entry = tk.Entry(root)
weight_entry.pack()

tk.Label(root, text="Height (cm)").pack()
height_entry = tk.Entry(root)
height_entry.pack()

tk.Button(root, text="Calculate BMI", command=calculate_bmi).pack(pady=10)

tk.Label(root, textvariable=bmi_result, font=("Arial", 14)).pack()
tk.Label(root, textvariable=category, font=("Arial", 12)).pack()
tk.Label(root, textvariable=diet, wraplength=300, justify="center").pack(pady=10)

root.mainloop()

🎨 Features of This App

  • Simple and beginner-friendly GUI
  • Instant BMI calculation
  • Smart diet suggestions
  • No API required
  • Works offline

🚀 How to Run the Project

  1. Install Python
  2. Save the file as bmi_calculator.py
  3. Run the command:

python bmi_calculator.py
BMI Calculator with Diet Suggestion thumbnail

❓ FAQ

Q1. Is BMI accurate?
BMI is a general guideline and may not consider muscle mass.

Q2. Can I use this project for my portfolio?
Yes, it’s great for beginners and showcases both health and programming.

Q3. Can I improve this app?
Yes, you can add charts, save data, or convert it into a mobile app.

🧾 Conclusion

A BMI Calculator with Diet Suggestion is a powerful combination of health awareness and programming.

Previous Post Next Post

Contact Form