Month Offset¶
Write a function to give you the “month offset” given a number representing the month. This refers to the day of the week the month starts on (months don’t all start on a Sunday, but throught the week). You can get the month offset from the following table:
Month | Month offset |
---|---|
1 | 1 |
2 | 4 |
3 | 4 |
4 | 0 |
5 | 2 |
6 | 5 |
7 | 0 |
8 | 3 |
9 | 6 |
10 | 1 |
11 | 4 |
12 | 6 |
anything else | -1 |
Of course, here’s the starter code to test your function.
Offset for month 1: 1
Offset for month 2: 4
Offset for month 3: 4
Offset for month 4: 0
Offset for month 5: 2
Offset for month 6: 5
Offset for month 7: 0
Offset for month 8: 3
Offset for month 9: 6
Offset for month 10: 1
Offset for month 11: 4
Offset for month 12: 6
Offset for month 43: -1
©2021 Daniel Gallo
This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Adapted for Python from Graham Mitchell’s Programming By Doing