Age Calculator GUI Project
An age calculator is a tool or program used to determine a person's age. It works by taking in a person's date of birth and comparing it with the current date to determine the person's age in years, months, and days. Age calculators are useful in various fields such as healthcare, finance, and legal services.
In programming, an age calculator can be implemented using date and time functions available in programming languages such as Python, Java, and JavaScript. The calculation of age involves subtracting the birth date from the current date, considering factors such as leap years, months, and days.
The result is then formatted into years, months, and days, depending on the required output format.
Age calculators are commonly used in medical facilities to track the age of patients and monitor their health progress. In the financial sector, age calculators are used to calculate interest rates and manage retirement funds.
Age calculators can also be used in legal services, especially in cases that require verifying a person's age.
Overall, an age calculator is a valuable tool that helps to determine a person's age accurately and efficiently.
It is widely used in various fields, and its implementation is relatively easy, thanks to the availability of date and time functions in programming languages.
In this project we are created age calculator.
You have to type your date of birth in simple way,
date,month and year.
We are added some logics to calculate age..
importing modules from tkinter import * from datetime import date #Subscribe our PyCoder YouTube Channel #A kiran Rajput #www.diplomastudymaterial.tech root=Tk() #creating window root.title("AGE-CALCULATOR") #setting up title root.configure(bg="#D5C6FF") #setting up backround color root.geometry("400x300") #fixing the size of the window new=Label(root,bg="#000000") #declaring a lable new.grid(row=5,column=0,columnspan=3) today=str(date.today()) #getting current date using datetime module list_today=today.split("-") #converting into a list #defining a function to calcutate age def age(b_date,b_month,b_year): global today global new new.grid_forget() b_date=int(entry_date.get()) b_month=int(entry_month.get()) b_year=int(entry_year.get()) c_date=int(list_today[2]) c_month=int(list_today[1]) c_year=int(list_today[0]) month =[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] if(b_date>c_date): c_month=c_month-1 c_date=c_date+month[b_month-1] if (b_month>c_month): c_year=c_year-1 c_month=c_month+12 resultd=str(c_date-b_date) resultm=str(c_month-b_month) resulty=str(c_year-b_year) new=Label(root,text="YOUR AGE \n"+resulty+" YEARS "+resultm+" MONTHS "+ resultd+" DAYS ",fg="#FFFFFF",bg="#3498DB",borderwidth=6) new.config(font=("Arial Rounded MT Bold",15)) new.grid(row=5,column=0,columnspan=3) #defining a function to clear the previous entries def clean(entry_date,entry_month,entry_year): global new new.grid_forget() entry_date.delete(0,END) entry_month.delete(0,END) entry_year.delete(0,END) #creating widgets such as labels,entry boxes and buttons and fixing its position onto window title_label=Label(root,text="AGE CALCULATOR",borderwidth=35,fg="#36454F",bg="#A7C7E7") title_label.config(font=("Broadway",29)) title_label.grid(row=0,column=0,columnspan=3) label_date=Label(root,text="BIRTH DATE : ",borderwidth=4,fg="#088F8F",bg="#D5C6FF") label_date.config(font=("Arial Rounded MT Bold",15)) label_date.grid(row=1,column=0) label_month=Label(root,text="BIRTH MONTH : ",borderwidth=5,fg="#088F8F",bg="#D5C6FF") label_month.config(font=("Arial Rounded MT Bold",15)) label_month.grid(row=2,column=0) label_year=Label(root,text="BIRTH YEAR : ",borderwidth=9,fg="#088F8F",bg="#D5C6FF") label_year.config(font=("Arial Rounded MT Bold",15)) label_year.grid(row=3,column=0) copyright=Label(root,text="if you want more project visit our site and download project in free",borderwidth=5,fg="#088F8F",bg="#D5C6FF") copyright.config(font=("Arial Rounded MT Bold",5)) copyright.grid(row=6,column=0) copyright=Label(root,text="www.diplomastudymaterial.tech",borderwidth=5,fg="#088F8F",bg="#D5C6FF") copyright.config(font=("Arial Rounded MT Bold",5)) copyright.grid(row=7,column=0) copyright=Label(root,text="& Subscribe Our 'PyCoder'' YouTube channel",borderwidth=5,fg="#088F8F",bg="#D5C6FF") copyright.config(font=("Arial Rounded MT Bold",5)) copyright.grid(row=8,column=0) entry_date=Entry(root,width=20,borderwidth=3) entry_month=Entry(root,width=20,borderwidth=3) entry_year=Entry(root,width=20,borderwidth=3) entry_date.grid(row=1,column=2) entry_month.grid(row=2,column=2) entry_year.grid(row=3,column=2) #getting the value in the entry boxes b_date=entry_date.get() b_month=entry_month.get() b_year=entry_year.get() #calling age function in button widget submit=Button(root,text="GET AGE!!",width=10,anchor=CENTER,command=lambda:age(b_date,b_month,b_year),bg="#008080",fg="#FFFFFF",borderwidth=5) submit.grid(row=4,column=0) #calling clean function in button widget clear=Button(root,text="CLEAR",width=10,command=lambda:clean(entry_date,entry_month,entry_year),bg="#008080",fg="#FFFFFF",borderwidth=5) clear.grid(row=4,column=2) root.mainloop() #PyCoder #A Kiran Rajput #www.pycods.blogspot.com