-
Notifications
You must be signed in to change notification settings - Fork 0
/
answer2.py
62 lines (48 loc) · 1.46 KB
/
answer2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Bennett Wenger
# 2/29/2016
# Python Group Challenge
# imports
import calendar
# methods
# main menu
def main_menu():
print("***** Leap Day Convergence Calculator *****")
print("\nIt's February 29th, 2016.")
print("This week's python meet is happening on Leap Day!")
print("Using Python, we'll calculate when this \namazing occurence will happen next.")
input("\nPress [Enter] to get to it!")
# exit prompt
def exit_prompt():
input("\nPress [Enter] to exit.")
# calculate
def calculate():
# Parameters:
# Python meets happen on the last Monday of each month.
# Leap Day happens every fourth year.
# declare containers
febList = []
fifthWeek = []
# other declarations
controlBool = True
myYear = 2016
# loop through time
while (controlBool):
myFebruary = calendar.monthcalendar(myYear, 2)
febList = myFebruary
listLength = len(febList)
# specify the search
if (listLength == 5):
fifthWeek = febList[4]
myMonday = fifthWeek[0]
# test for a convergence
if ((myYear > 2016) and (myMonday == 29)):
break
# increment year
myYear += 1
print("\nThe next Leap Day Python Meet \nwill occur on February 29, " + str(myYear))
# main logic
main_menu()
calculate()
exit_prompt()
# end of program