Skip to content

Instantly share code, notes, and snippets.

@rvause
Created August 17, 2011 13:44
Show Gist options
  • Save rvause/1151545 to your computer and use it in GitHub Desktop.
Save rvause/1151545 to your computer and use it in GitHub Desktop.
My partner got me totally confused about how old, I, and everyone else is; so this is to prove my own age to myself.
#!/usr/bin/env python
import sys
MONTHS_IN_YEAR = 11
class Age(object):
years = 0
months = 0
def __init__(self, *args, **kwargs):
self.start = kwargs.get('start', 1984)
self.end = kwargs.get('end', 2011)
def increment_month(self):
self.months += 1
return self.months
def increment_year(self):
self.years += 1
return self.years
def run_simulation(self):
for year in range(self.start, self.end):
print 'The year is %s' % year
for month in range(0, MONTHS_IN_YEAR):
print 'You are %s years and %s months' % (
self.years,
self.increment_month(),
)
print 'That was your birthday, you are now %s' % self.increment_year()
self.months = 0
if __name__ == '__main__':
try:
age = Age(start=int(sys.argv[1]), end=int(sys.argv[2]))
except IndexError:
age = Age()
age.run_simulation()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment