""" date_v1.py date object - class exercise IntroCS - April 12 2021 Create a MyDate class which (a) stores the month, day, and year (b) has a .short_form() method that returns e.g. "04/12/2021" string (c) has a .long_form() method that returns "April 12 2021" string. _v1 : version 1 : what Jim did in class. This is what happens when you run this : $ python date_v1.py -- working with dates -- What is the date (month/day/year) ? 2/3/2021 The date is 2/3/2021 The date is also Feb 3 2021 """ month_names = [ None, 'January', 'Feb', 'Mar', # ... type the rest ] class MyDate: def __init__(self, month, day, year): self.month = month self.day = day self.year = year def get_short_form(self): return f"{self.month}/{self.day}/{self.year}" def get_long_form(self): month = month_names[self.month] return f"{month} {self.day} {self.year}" def new_date(): """ create and return date from user input """ date_string = input("What is the date (month/day/year) ?") (month, day, year) = date_string.split('/') (month, day, year) = (int(month), int(day), int(year)) mydate = MyDate(month, day, year) return mydate def main(): print("-- working with dates -- ") date = new_date() #print(" date month is ", date.month) # debugging #print(" date day is ", date.day) #print(" date year is ", date.year) print("The date is ", date.get_short_form()) print("The date is also ", date.get_long_form()) if __name__ == '__main__': main()