You can download this code by clicking the button below.
This code is now available for download.
Calculate the age given a birthdate.
Technology Stack : datetime, math, os, re, sys
Code Type : Function
Code Difficulty : Intermediate
import datetime
import math
import os
import re
import sys
def calculate_age(birthdate):
today = datetime.date.today()
age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))
return age