top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Writer's pictureVanessa Arhin

AGE Calculator using Python



Age is an important concept of life. The age of an non-living or living thing is used to how old it is. Age is usually calculated using the time something begins to exist and current time/the time it stops existing.

This article contains a program that calculates the period of existence in years. From the date it begins to existence to the current date, given that the user provides the date it begins to exist.


The user has to provide the year, month and day, all in figures.

year = int(input('Enter your year of birth(yyyy):'))
month = int(input('Enter your month of birth(mm):'))
day = int(input('Enter your day of birth(dd):')) 

The program then subtracts the date provided by the user from the current date depending on their geographical location.



current_date = dt.datetime.now()
start_date = dt.datetime(year,month, day)

years = (current_date - start_date)/365

years = str(years)


The age in years, is then displayed.



1 comment

1 Comment


Data Insight
Data Insight
Sep 18, 2021

Nice. But no examples given.

Like
bottom of page