def __init__(self, day, month, year): if not isinstance(day, int) or not isinstance(month, int) or not isinstance(year, int): print('Date must be initialized with numbers') return if month < 1 or month > 12: print('Month must be between 1 and 12') return if mydate.is_leap_year(year): days = mydate.days_in_months_leap_year[month - 1] else: days = mydate.days_in_months[month - 1] if day < 1 or day > days: print('Day must be between 1 and ', days) return self.day = day self.month = month self.year = year
#!/usr/bin/python3 import mydate for i in mydate.months_name: print('month is ', i) print('this month has', mydate.get_num_of_days_in_month(i), 'days') print('this month is followed by', mydate.get_following_month(i)) for year in range(2000, 2010): if mydate.is_leap_year(year): print('year', year, 'is a leap year')
#!/usr/bin/env python import mydate for i in mydate.months_name: print('month is ', i) print('this month has', mydate.get_num_of_days_in_month(i), 'days') print('this month is followed by', mydate.get_following_month(i)) for year in range(2000, 2010): if mydate.is_leap_year(year): print('year', year, 'is a leap year')