Last active
May 19, 2016 00:56
-
-
Save peterldowns/82bbc7efdf263d1c8b74e8163b3376b0 to your computer and use it in GitHub Desktop.
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/env python | |
| # coding: utf-8 | |
| """ | |
| The power of numbers is never more evident than when we use them to speculate | |
| on the time of our dying. Sometimes I bargain with myself. Would I be willing | |
| to accept sixty-five, Genghis Khan's age on dying? Suleiman the Magnificent | |
| made it to seventy-six. That sounds all right, especially the way I feel now, | |
| but how will it sound when I'm seventy-three? | |
| Don DeLillo, White Noise | |
| """ | |
| from datetime import datetime as dt | |
| adult_age = 18 | |
| death_age = 50 | |
| birth_dt = dt(year=1994, month=1, day=20) | |
| adult_dt = birth_dt.replace(year=1994+adult_age) | |
| death_dt = birth_dt.replace(year=1994+death_age) | |
| now_dt = dt.utcnow() | |
| birth = birth_dt.toordinal() | |
| adult = adult_dt.toordinal() | |
| now = now_dt.toordinal() | |
| death = death_dt.toordinal() | |
| days_lived = now - birth | |
| days_adult = now - adult | |
| days_remaining = death - now | |
| lived_percentage = days_lived / float(death - birth) * 100 | |
| adult_percentage = days_adult / float(death - adult) * 100 | |
| def main(): | |
| print '{} days gone ({} as an adult), {} remaining ({:.2f}% alive, {:.2f}% adult)'.format( | |
| days_lived, days_adult, days_remaining, lived_percentage, adult_percentage) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.