成績
from tkinter import *
a=Tk()
a.title('成績')
a.geometry('400x400')
L1=Label(a,text="數(shù)學(xué):")
L2=Label(a,text="語文:")
L3=Label(a,text="英語:")
L1.grid(row=0, column=0)
L2.grid(row=1, column=0)
L3.grid(row=2, column=0)
H=Entry(a,width=30)
H.grid(row=0, column=1)
W=Entry(a,width=30)
W.grid(row=1, column=1)
Y=Entry(a,width=30)
Y.grid(row=2, column=1)
L4=Label(a,text='')
L5=Label(a,text='')
L4.grid(row=3,column=1)
L5.grid(row=4,column=1)
def u():
? ? m=float(H.get())
? ? n=float(W.get())
? ? y=float(Y.get())
? ? p=(m+n+y)/3
? ? L4.config(text=str(p))
? ? if p<60:
? ? ? ? L5.config(text='不及格')
? ? elif p>=60 and p<85:
? ? ? ? L5.config(text='及格')
? ? elif p>=85 and p<100:
? ? ? ? L5.config(text='優(yōu)秀')
? ? elif p==100:
? ? ? ? L5.config(text='滿分')
? ? else :
? ? ? ? L5.config(text='你輸入有問題')
J=Button(a,text='計(jì)算',command=u)
J.grid(row=5, column=1)
mainloop()