Simple python program to calculate your age

import datetime
print("##### Welcome to age calculator ######")
birth_year = int(input("Enter your year of birth: \n"))
birth_month = int(input("Enter your month of birth: \n"))
birth_day = int(input("Enter your day of birth: \n"))
current_year =
current_month =
current_day =
age_year = current_year - birth_year
age_month = abs(current_month-birth_month)
age_day = abs(current_day-birth_day)
print("Your exact age is: ", age_year, "Years", age_month, "months and", age_day, "days")

Output should look something like below:
##### Welcome to age calculator ######
Enter your year of birth: 
Enter your month of birth: 
Enter your day of birth: 
Your exact age is:  34 Years 2 months and 2 days

2 thoughts on “Simple python program to calculate your age

  1. This simply doesn’t work. you will need to create loops to determine whether a person has crossed a specific month time frame. I just started learning python and created one just was looking for a much more efficient way.
    from datetime import date

    todays_date =

    print(“Current date: “, todays_date)

    print(“Current year:”, todays_date.year)
    print(“Current month:”, todays_date.month)
    print(“Current day:”,

    birth_date = int(input(“Enter The date of your birth:”))

    birth_month = int(input(“Enter The month of your birth:”))

    birth_Year = int(input(“Enter The year of your birth:”))

    #we will create a variable dy that is the age that is determined only by knowing the year of birth

    dy = todays_date.year – birth_Year
    ldy = dy-1

    if todays_date.month > birth_month:
    print(f”you are {dy} years old”)

    elif todays_date.month = birth_date:
    print(f”you are {dy} years old”)

    elif < birth_date:
    print(f"you are {ldy} years old")

Leave a Reply