Last active
August 29, 2015 14:23
-
-
Save joedborg/c8613a671cd312aee505 to your computer and use it in GitHub Desktop.
How old am I?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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