1from datetime import date
2
3def calculate_age(born):
4 today = date.today()
5 return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
1today_date = datetime.datetime.now()
2dob = datetime.datetime(1982, 5, 20)
3print(today_date - dob)
1#Python Calculate Age from date of birth:
2
3from datetime import date
4
5def calculate_age(born):
6 today = date.today()
7 return today.year - born.year - ((today.month, today.day) < (born.month, born.day))