Showing posts with label how to calculate Age. Show all posts
Showing posts with label how to calculate Age. Show all posts

Monday, 18 September 2017

how to calculate Age


write a program to calculate age in python:

import  datetime
year=datetime.datetime.now().year
year_of_birth=int(input("enter your birth year: "))
print("you are %i years old!"%(year-year_of_birth))

Output:

enter your birth year: 1991
you are 26 years old!