-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBMI_Calculator.py
59 lines (41 loc) · 1.4 KB
/
BMI_Calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#This Tk for Calculate BMI use Tkinter
#This Program is Made to challenge myself, I call the program is One Day, One Program
#Program at June, 26, 2022
#Thank you
import tkinter as tk
def cal_bmi():
height = int(e1.get())
weight = int(e2.get())
BMI = weight / int((height/100)**2)
if BMI < 18.5 :
text.set("Your BMI Index: " + str(BMI) + " UnderWeight")
lhasil.config
elif BMI > 18.5 and BMI < 24.9 :
text.set("Your BMI Index: " + str(BMI) + " Normal")
lhasil.config
elif BMI > 25 and BMI < 29.9 :
text.set("Your BMI Index: " + str(BMI) + " OverWeight")
lhasil.config
elif BMI > 30 :
text.set("Your BMI Index: " + str(BMI) + " very OverWeight")
lhasil.config
else :
text.set("Wrong Format")
lhasil.config
master = tk.Tk()
master.title("BMI Calculator")
l1=tk.Label(master, text="Enter Your Height (Cm)")
l2=tk.Label(master, text="Enter Your Weight (Kg)")
e1=tk.Entry(master)
e2=tk.Entry(master)
btn=tk.Button(master, text="Calculate", command=cal_bmi)
text = tk.StringVar()
text.set(" ")
lhasil=tk.Label(master,font=('Helvetica', 12, 'bold'),textvariable=text)
l1.grid(row=0, column=0)
l2.grid(row=1, column=0)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
btn.grid(row=2, column=1)
lhasil.grid(row=3, column=1)
master.mainloop()