from tkinter import * def lab(t,b,f,x,y): Label(r,text=t,bg=b,fg=f).place(x=x,y=y) r=Tk() r.geometry('400x500') Frame(r,bg='navy',width=400,height=500).place(x=0,y=0) Frame(r,bg='orange',width=350,height=120).place(x=25,y=80) Frame(r,bg='yellow',width=350,height=130).place(x=25,y=220) Frame(r,width=70,height=30).place(x=165,y=370) lab('DAY-1','pink','black',70,90) lab('MONTH-1','pink','black',180,90) lab('YEAR-1','pink','black',290,90) lab('DAY-2','orange','black',70,240) lab('MONTH-2','orange','black',180,240) lab('YEAR-2','orange','black',290,240) e1=Entry(r,width=70) e1.place(x=70,y=130,width=50) e2=Entry(r,width=70) e2.place(x=180,y=130,width=50) e3=Entry(r) e3.place(x=290,y=130,width=50) e4=Entry(r) e4.place(x=70,y=280,width=50) e5=Entry(r) e5.place(x=180,y=280,width=50) e6=Entry(r) e6.place(x=290,y=280,width=50) Label(r,text='Age Calculator',bg='cyan',fg='black').place(x=170,y=20) def age(): d=int(e1.get()) m=int(e2.get()) y=int(e3.get()) da =int(e4.get()) mo=int(e5.get()) ye=int(e6.get()) y_a=y+1 y_b=ye-1 num=0 while y_a<=y_b: if y_a%4==0: num=num+366 y_a=y_a+1 else : num=num+365 y_a=y_a+1 if y!=ye: def ab(): if ye%4==0: if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+60) elif mo==4: return (da+91) elif mo==5: return (da+121) elif mo==6: return (da+152) elif mo==7: return (da+182) elif mo==8: return (da+213) elif mo==9: return (da+244) elif mo==10: return (da+274) elif mo==11: return (da+305) elif mo==12: return (da+335) else : if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+59) elif mo==4: return (da+90) elif mo==5: return (da+120) elif mo==6: return (da+151) elif mo==7: return (da+181) elif mo==8: return (da+212) elif mo==9: return (da+243) elif mo==10: return (da+273) elif mo==11: return (da+304) elif mo==12: return (da+334) def bc(): if y%4==0: if m==1: return (366-d) elif m==2: return (335-d) elif m==3: return (306-d) elif m==4: return (275-d) elif m==5: return (245-d) elif m==6: return (214-d) elif m==7: return (184-d) elif m==8: return (153-d) elif m==9: return (122-d) elif m==10: return (92-d) elif m==11: return (61-d) elif m==12: return (31-d) else : if m==1: return (365-d) elif m==2: return (334-d) elif m==3: return (306-d) elif m==4: return (275-d) elif m==5: return (245-d) elif m==6: return (214-d) elif m==7: return (184-d) elif m==8: return (153-d) elif m==9: return (122-d) elif m==10: return (92-d) elif m==11: return (61-d) elif m==12: return (31-d) abv=ab()+bc()+num O['text']=str(abv) else: def ab(): if ye%4==0: if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+60) elif mo==4: return (da+91) elif mo==5: return (da+121) elif mo==6: return (da+152) elif mo==7: return (da+182) elif mo==8: return (da+213) elif mo==9: return (da+244) elif mo==10: return (da+274) elif mo==11: return (da+305) elif mo==12: return (da+335) else : if mo==1: return (da) elif mo==2: return (da+31) elif mo==3: return (da+59) elif mo==4: return (da+90) elif mo==5: return (da+120) elif mo==6: return (da+151) elif mo==7: return (da+181) elif mo==8: return (da+212) elif mo==9: return (da+243) elif mo==10: return (da+273) elif mo==11: return (da+304) elif mo==12: return (da+334) def bc(): if y%4==0: if m==1: return (d) elif m==2: return (d+31) elif m==3: return (d+60) elif m==4: return (d+91) elif m==5: return (d+121) elif m==6: return (d+152) elif m==7: return (d+182) elif m==8: return (d+213) elif m==9: return (d+244) elif m==10: return (d+274) elif m==11: return (d+305) elif m==12: return (d+335) else : if m==1: return (d) elif m==2: return (d+31) elif m==3: return (d+59) elif m==4: return (d+90) elif m==5: return (d+120) elif m==6: return (d+151) elif m==7: return (d+181) elif m==8: return (d+212) elif m==9: return (d+243) elif m==10: return (d+273) elif m==11: return (d+304) elif m==12: return (d+334) aav=ab()-bc() O['text']=str(aav) O=Label(r) Button(r,text='Compute',bg='orange',command=age).place(x=170,y=420) Button(r,text='QUIT',bg='orange',command=r.destroy).place(x=178,y=460) O.place(x=175,y=375) r.mainloop()