Calculate Your Age in Minutes with a Simple Python Script

Are you curious about how many minutes you've been alive? Check out this easy-to-use Python script that calculates your age in minutes. With built-in error handling, you can ensure accurate results every time. Plus, download the executable file to use on your own computer. Don't miss out on this fun and informative tool for programmers and non-programmers alike!
How many minutes have passed since my birth? How many weeks or days have I existed? This simple script answers all of that. You input your date of birth - day, month, and year - and the script tells you everything.
For example, someone born on May 1st, 1980 has lived 14,904 days or 21,461,760 minutes. If that isn't interesting information, then what is?

In the code, in addition to using the relatively simple "daytime," I tried to exclude all possible errors that could be recorded so that the program wouldn't crash.
For example, if someone enters text or symbols instead of a number, Python would produce an error and the window would close. Now, if someone enters that they were born on the 32nd of the month, the program will give them a polite error message asking them to enter the correct date.
This is done using while loops in combination with try-except for specific errors that may arise. It is the duty of a good programmer to exclude future incorrect entries from users and strengthen the program. Because nothing is worse than something that doesn't work properly or crashes all the time.

The entire program code is below. Anyone interested can download the exe here. The exe is not a virus, and as I wrote in another post, it has been checked on Virus Total, but Google may display it as an uncommon download.
import datetime
def how_old():
currentDate = datetime.datetime.now()
year_born = input("Enter the year you were born in the form yyyy (for example 1976): ")
while True:
try:
if int(year_born) not in range(1, 11111111):
year_born = input("Enter a valid year in the form yyyy: ")
elif len(year_born) != 4:
year_born = input("Enter at least 4 digits in the form yyyy: ")
else:
break
except ValueError:
print("Only integers are allowed! ")
year_born = input("Enter the year you were born in the form yyyy (for example 1976): ")
month_born = input("Enter the month you were born in the form mm (for example 05 for May): ")
while True:
try:
if int(month_born) not in range(1, 13):
month_born = input("Enter a valid month in the form mm: ")
else:
break
except ValueError:
print("Only integers are allowed! ")
month_born = input("Enter the month you were born in the form mm (for example 05 for May): ")
date_born = input("Enter the date you were born in the form dd (for example 17): ")
while True:
try:
if int(date_born) not in range(1, 32):
date_born = input("Enter a valid date in the form dd: ")
else:
break
except ValueError:
print("Only integers are allowed! ")
date_born = input("Enter the date you were born in the form dd: ")
tot_date2 = {date_born + "/" + month_born + "/" + year_born}
tot_date = ''.join(tot_date2)
deadlineDate = datetime.datetime.strptime(tot_date, '%d/%m/%Y')
print (deadlineDate)
daysLeft = currentDate - deadlineDate
#print(daysLeft)
years = ((daysLeft.total_seconds())/(365.242*24*3600))
yearsInt=int(years)
months=(years-yearsInt)*12
monthsInt=int(months)
days=(months-monthsInt)*(365.242/12)
daysInt=int(days)
hours = (days-daysInt)*24
hoursInt=int(hours)
minutes = (hours-hoursInt)*60
minutesInt=int(minutes)
seconds = (minutes-minutesInt)*60
secondsInt =int(seconds)
num_days = currentDate - deadlineDate
print('\nYou are {0:d} years, {1:d} months, {2:d} days, {3:d} hours, '
'{4:d} minutes, {5:d} seconds old.'.format(yearsInt,monthsInt,daysInt,hoursInt,minutesInt,secondsInt))
num_months = (currentDate.year - deadlineDate.year) * 12 + (currentDate.month - deadlineDate.month)
print("\nYou are alive for: \n" + "---" + str(num_months) + " months or ")
num_weeks = num_days.days / 7
num_weeks = int(num_weeks)
print("---" + format((num_weeks), "0,d") + " weeks or")
num_days = currentDate - deadlineDate
print("---" + format((num_days.days), "0,d") + " days or ")
num_hours = int(num_days.days) * 24
print("---" + format((num_hours), "0,d") + " hours or")
num_minutes = num_hours * 60
print("---" + format((num_minutes), "0,d") + " minutes")
how_old()
while True:
play_or_quit = input("\npress 'p' to enter again or 'q' to exit: ")
if play_or_quit.lower() == "p":
how_old()
else:
if play_or_quit.lower() == "q":
exit(0)