# Untitled

unknown
plain_text
a year ago
2.0 kB
1
Indexable
Never
```def leapyear(year):
if year%100!=0 :
if year%4==0:
return True
else :
if year%400==0:
return True
return False
def numSunday(year):
firstSun=1
first=1
numSundays=0
for i in range(1900, year+1):
#jan
firstSun=(firstSun+31)%7
if firstSun==0:
if i==year:
numSundays+=1
#feb
if leapyear(year):
firstSun=(firstSun+29)%7
if firstSun==0:
if i==year:
numSundays+=1
else :
firstSun=(firstSun+28)%7
if firstSun==0:
if i==year:
numSundays+=1
#mar
firstSun=(firstSun+31)%7
print (firstSun)
if firstSun==0:
if i==year:
numSundays+=1
#apr
firstSun=(firstSun+30)%7
if firstSun==0:
if i==year:
numSundays+=1
#may
firstSun=(firstSun+31)%7
if firstSun==0:
if i==year:
numSundays+=1
#june
firstSun=(firstSun+30)%7
if firstSun==0:
if i==year:
numSundays+=1
#july
firstSun=(firstSun+31)%7
if firstSun==0:
if i==year:
numSundays+=1
#aug
firstSun=(firstSun+31)%7
if firstSun==0:
numSundays+=1
#sept
firstSun=(firstSun+30)%7
if firstSun==0:
if i==year:
numSundays+=1
#oct
firstSun=(firstSun+31)%7
if firstSun==0:
if i==year:
numSundays+=1
#nov
firstSun=(firstSun+30)%7
if firstSun==0:
if i==year:
numSundays+=1
#dec
firstSun=(firstSun+31)%7
if firstSun==0:
if i==year:
numSundays+=1

return numSundays
print (numSunday(1900))```