Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def isLeap(year):
- ____
- # [CLUE] ^ Define 'isLeap()' before proceeding.
- # [CLUE] ^ Only include years that are divisible by 4 or are centuries divisible by 400.
- def whatday(date,mth,year=2017):
- #your code here
- mths = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
- weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
- # dimth: List of total days in month.
- dimth = [___] # [CLUE] Number of days in each month. You may substitute any number for Feb for now.
- if not isLeap(year):
- dimth[___] = 28 # [CLUE] Refer to the indices in 'mths'.
- else:
- dimth[___] = 29 # [CLUE] Same index as above.
- mth = mths.index(mth) + ___
- # ^ [CLUE] Convert the month name to its equivalent numeral ('Feb' gives 2, 'Mar' gives 3).
- # ^ [CLUE] Recall that list indices start from zero.
- offset = -2
- days = 0
- for y in range(year):
- if isLeap(y):
- days += ___ # [CLUE] How many days are there in a leap year?
- else:
- days += ___ # [CLUE] How many days are there in a non-leap year?
- for m in range(mth-1):
- days += ___[_]
- # [CLUE] ^ Use the list of days in months to find the number of days passed.
- # [CLUE] ^ The index to use has been adjusted for you.
- return weekdays[(
- offset
- + days
- + date
- ) % 7]
- for item in [
- (1,'Jun'), # Thu
- (28,'Feb'), # Tue
- (31,'Dec'), # Sun
- (12,'Dec',2017), # Tue
- (14,'Feb',2021), # Sun
- (31,'Dec',2055) # Fri
- ]:
- print(item, whatday(*item))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement