In [3]:
print("Hello this is a age convertor python program!") #This is the introduction of the program. 

from datetime import datetime #This is from the python library that gets the date and time and imports it into the program for calculations.

age = int(input("What is your age in years? ")) #This allows the user to input their age in years.

def calculations(age): #Defining a function that will do calculations with the user's age throughout the program. 
    current_day = datetime.now() #This allows the program to input the date library to the date so when the current day is called, it refers to the day library.
    year = current_day.year - age #This allows the program to subtract the current year by the age in order to calculate how many year it has been.
    
    months = int(input("What is the month you were born in? (1st month to 12th month): ")) #This is asks for the users input of what monththey were born in for calculations.
    days = int(input("What day will your birthday be? ")) #This is asking when the users birthday will be so the day they were born.
    
    upcoming_bday = datetime(current_day.year, months, days) #This is used to calculate how long your birthday will come, so it is taking the current day, year, and month in order to subtract it from the current one. 
    
    if upcoming_bday < current_day: #This is seeing if your upcoming birthday is passed then it will calculate the statement below. 
        upcoming_bday = datetime(current_day.year + 1, months, days) #This is showing if your upcoming birthday is passed then it will add 1 to the year since it will be next year, so the statement above must be true for it to work.
        
    time_range = upcoming_bday - current_day #This is calculating the time range of when your upcoming birthday will come to the current day. 
    
    ageDays = age * 365 #This is the calculation of the age and it is converting it to the days.
    print("") #This line creates spacing between the outputs.
    print("You are", ageDays, "days old.") #This is a print statement showing how many days you are old.
    ageMonths = int(ageDays/30) #This is the calculation of the months and it is converting it, so that it will be every 30 days in the month
    ageDays %= 30 #This is if the days do not entirely equal to the number of days in the month, so the remainder.
    
    print("You are", age, "years old.") #This is a print statement that prints the users age.
    print("Your upcoming birthday is on", upcoming_bday.strftime("%Y-%m-%d")) #This is printing out when the user's upcoming birthday will be. 
    print("There is", time_range.days, "days until your next birthday.") #This is printing out the time range of when the user's birthday will come. 
    print("You are about", ageMonths, "months and", ageDays, "days old.") #This is printing out the conversion of the user's age to the months and days. 
        
def leave(): #Creating a function to leave the program   
    again = input("Do you want to calcualte your age again? ") #This is asking the user if they want to calculate their age again. 
    if again.lower() == "yes": #This is a print statement that shows if the user's decision is yes then it the function will be called again.
        age = int(input("What is your age in years? ")) #This allows the user to input their age in years.
        calculations(age) #This is calling the function to calculate the user's age. 
    else: #This is if the user's decision is something besides yes, so if it is no 
        print("Have a good day!!") #This is a print statement showing the user that the program has ended and to have a good day. 

calculations(age) #This is calling the function since it is the end of the program. 
leave() #Calling the function to leave the program
Hello this is a age convertor python program!
What is your age in years? 58
What is the month you were born in? (1st month to 12th month): 5
What day will your birthday be? 11

You are 21170 days old.
You are 58 years old.
Your upcoming birthday is on 2024-05-11
There is 3 days until your next birthday.
You are about 705 months and 20 days old.
Do you want to calcualte your age again? yes
What is your age in years? 3
What is the month you were born in? (1st month to 12th month): 7
What day will your birthday be? 5

You are 1095 days old.
You are 3 years old.
Your upcoming birthday is on 2024-07-05
There is 58 days until your next birthday.
You are about 36 months and 15 days old.
In [ ]:
 
In [ ]: