-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp019.py
More file actions
34 lines (32 loc) · 1.08 KB
/
Copy pathp019.py
File metadata and controls
34 lines (32 loc) · 1.08 KB
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
def is_leap(year):
""" Returns True if the year is leap
The year is leap if is divisible by four and not a century year
or if it is a century year divisible by 400
Parameters
----------
year: int
Returns
-------
True if year is a leap year and False if it is not a leap year
"""
if year%4==0 and ( year%100!=0 or year%400==0):
return True
else:
return False
if __name__ == '__main__':
#Mon: Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,Jan
dpm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
dd = 1 # 1 Jan 1900 is Monday
cnt = 0 # therefore initial count is 0
year = 1900
while year <= 2000:
for month in range(12):
dd += dpm[month]
if month==1 and is_leap(year):
dd += 1
if ( dd%7==0 # Is Sunday
and (year > 1900 or month==11) # After 1/Jan/1901
and (year < 2000 or month<11) ): # on or Before 1/Dec/2000
cnt += 1
year += 1
print(cnt)