<!DOCTYPE html>
Python Project: GUI BMI Calculator
Body Mass Index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. It is used to indicate whether an individual is underweight, overweight, or at a healthy weight.
This Python project involves creating a Graphical User Interface (GUI) for a BMI calculator. The user can input their height and weight, and the program will calculate their BMI and provide them with a classification (underweight, normal weight, overweight, or obese).
Features of the GUI BMI Calculator:
- Input fields for height and weight
- Calculate button to compute the BMI
- Display of the calculated BMI value
- Classification of the BMI value
Python Code:
import tkinter as tk
from tkinter import messagebox
def calculate_bmi():
try:
height = float(height_entry.get())
weight = float(weight_entry.get())
bmi = weight / (height ** 2)
bmi_label.config(text=f"Your BMI: {bmi:.2f}")
if bmi < 18.5:
classification = "Underweight"
elif bmi < 25:
classification = "Normal weight"
elif bmi < 30:
classification = "Overweight"
else:
classification = "Obese"
classification_label.config(text=f"Classification: {classification}")
except ValueError:
messagebox.showerror("Error", "Invalid input. Please enter numbers only.")
# Create the GUI
root = tk.Tk()
root.title("BMI Calculator")
height_label = tk.Label(root, text="Height (m):")
height_label.pack()
height_entry = tk.Entry(root)
height_entry.pack()
weight_label = tk.Label(root, text="Weight (kg):")
weight_label.pack()
weight_entry = tk.Entry(root)
weight_entry.pack()
calculate_button = tk.Button(root, text="Calculate BMI", command=calculate_bmi)
calculate_button.pack()
bmi_label = tk.Label(root, text="")
bmi_label.pack()
classification_label = tk.Label(root, text="")
classification_label.pack()
root.mainloop()
Conclusion:
Creating a GUI BMI calculator in Python is a great beginner project for those looking to practice their coding skills and learn how to work with graphical interfaces. With this program, users can quickly determine their BMI and assess their weight status based on the results.
Feel free to explore more functionalities and design improvements to enhance the user experience of the BMI calculator!
ممكن مشاريع للمبتدئين الخاصة ب الذكاء الإصطناعي وتعلم الآلة
❤❤
ماشاء الله استمر
https://youtu.be/ATWwePHXhDc?si=_nLkr139BuT7fqkK