""" age.py This is the start of a a program that finds your age in years months, and days. Here's what it looks like so far, running it with the doctest "-v" verbose flag. $ python age.py -v 5 items had no tests: __main__ __main__.get_days_months_years __main__.is_valid __main__.main __main__.parse 0 tests in 5 items. 0 passed and 0 failed. Test passed. -- age calculator -- When were you born? (i.e. 10/12/2001) ????? You are ? days, ? months, and ? years old. This is an class exercise designed to work on functions, specificiations, tests, finding APIs, using "if" statements ... all that good stuff. YOUR MISSION - should you decide to accept it - is to (a) design what inputs & outputs are appropriate for each function, (b) write tests for the functions (c) implement the functions Some places that might help to start looking for help: * google "python3 todays year day date" * google "python3 time between two dates" (And if we find answers online that we end up using, we should usually quote the URL in our code here.) While reading those you might want to look at python3 packages * datetime (installed by default) * calendar (ditto) * dateutil (not part of the python3 standard libary; can be added with "pip") And we might also want to understand some definitions like * ISO 8601 : https://en.wikipedia.org/wiki/ISO_8601 It turns out that dates and times are pretty complicated : leap years, time zones, different conventions in different places, ... Whether it's easier to write our own "figure out the date" algorithm or understand the API for (and perhaps install) a library ... is not always an obvious choice. But trynot to go too far down the rabbit hole. in class exercise on Oct 17 2019 (Oh, I mean 10/17/2019. Or is that 2019-10-17 ?) """ def is_valid(date_string): """ ... """ # TODO: decide what this does, make doctests, implement return '?' def parse(date_string): """ ... """ # TODO: decide what this does, make doctests, implement return '?' def get_days_months_years(date): """ ... """ # TODO: decide what this does, make doctests, implement return ('?', '?', '?') def main(): print("-- age calculator --") while True: user_input = input("When were you born? (i.e. 10/12/2001) ") if is_valid(user_input): date_of_birth = parse(user_input) break else: print("You typed '{}' which isn't a valid date. Please try again.") (days, months, years) = get_days_months_years(date_of_birth) print("You are {} days, {} months, and {} years old.".format( days, months, years)) # TODO: Change that last print statement appropriately if # there any of these are 0 or 1 (e.g. avoid saying "1 days"). if __name__ == '__main__': import doctest doctest.testmod() main()