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!

No comments:

Post a Comment