Last active
December 19, 2015 02:58
-
-
Save olemb/5886648 to your computer and use it in GitHub Desktop.
Compute your age in days and years.
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
#!/usr/bin/python | |
""" | |
howoldami - Compute your age in days and years. | |
Unix has whoami, but it's missing howoldami. No longer! | |
$ howoldami | |
You are 15884 days old (or 43.49 years) | |
- Ole Martin Bjørndalen | |
""" | |
import datetime | |
# Change birth_date to your birth date | |
birth_date = datetime.date(1970, 1, 1) | |
today = datetime.date.today() | |
age_in_days = (today - birth_date).days | |
age_in_years = age_in_days / 365.25 | |
print('You are {} days old (or {:.2f} years)'.format( | |
age_in_days, age_in_years)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment