Skip to content

Commit

Permalink
Merge pull request #286 from premdaripa/feature/BMI_Calculator
Browse files Browse the repository at this point in the history
Add BMI calculator with GUI
  • Loading branch information
Techiral authored Jul 12, 2024
2 parents f65a440 + b380e08 commit 7071a7e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions B/BMI_Calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import tkinter as tk

def calculate_bmi():
height = float(height_entry.get())
weight = float(weight_entry.get())
bmi = weight / (height ** 2)
result_label.config(text=f"BMI: {bmi:.2f}")

# Create the main window
root = tk.Tk()
root.title("BMI Calculator")

# Create and configure the widgets
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()

result_label = tk.Label(root, text="")
result_label.pack()

# Start the main event loop
root.mainloop()

0 comments on commit 7071a7e

Please sign in to comment.