Wednesday, May 29, 2024

How to build age calculator with python 3?

How to build age calculator with python 3?

Hello guy’s welcome back to my blog. Today in this blog post, I will tell you, How to build age calculator with python 3?

Guy’s in this post, I have used python 3.9.6 version.

Working Video
How to build age calculator with python 3?
How to build age calculator with python 3?

Here is the working video for how to install pandas in python 3.9.6:

Install pandas in python

Guy’s if you are new in Python then please check below link for more Python tutorials:

  1. Python Tutorials

Guy’s here is the working code snippet and please use it carefully:

1. Guy’s very first we need to installed python latest version and I have installed python 3.9.6 version. From below link please download the python latest version:

2. Now guy’s create empty folder name `demo`(optional) in your system’s any drive and inside demo folder create `` and add below code inside it:

# Python3 code to calculate age in years
from datetime import date

birthyear = int(input("Please enter your year of birth(1901) : "))
birthmonth = int(input("please enter your month of birth(01) : "))
birthdate = int(input("Plear enter your day of birth(31) : "))

def calculateAge(born):
  today =
    birthday = born.replace(year = today.year)

  # raised when birth date is February 29
  # and the current year is not a leap year
  except ValueError:
    birthday = born.replace(year = today.year,
        month = born.month + 1, day = 1)

  if birthday > today:
    return today.year - born.year - 1
    return today.year - born.year
# Driver code
print(calculateAge(date(birthyear, birthmonth, birthdate)), "years old.")

3. Now guy’s inside your project terminal run below command and run your first python program:


This is it guy’s. Guy’s if you have any kind of query then please comment below. Guy’s I will come with more demos soon.

For better live working experience please check the above working video.

I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.



the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.