Skip to content

Instantly share code, notes, and snippets.

@joedborg
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joedborg/c8613a671cd312aee505 to your computer and use it in GitHub Desktop.
Save joedborg/c8613a671cd312aee505 to your computer and use it in GitHub Desktop.
How old am I?
import math
from datetime import datetime
def how_old_am_i(year, month, day):
"""
Get how old you are in years.
:param year: Integer year born
:param month: Integer month born
:param day: Integer day born
:retuns: Integer years old
"""
birthday = datetime(year, month, day)
delta = datetime.now() - birthday
return int(math.floor(delta.days / 365))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment