@PiAir/

# Jarigopmoederdag

## No description

Files
• main.py
main.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
63
64
65
66
67
68
69
# My nephew was born on May 9.
# The year he was born, May 9 was Mothersday
# The question was: how often does his birthday coincide with Mothersday?
# In the Netherlands (Europe?) Mothersday always is on the second Sunday of May
# This script checks if that second Sunday = the 9th.

mybirthday = 9
mybirthyear = 1982

from datetime import date

def DayofMothersday(checkyear):
# print ("Checking:", checkyear)
sundayfound = 0
for checkday in range(1,15):
checkdate = date(checkyear,5,checkday)
# print ("Checking:", checkdate)
if checkdate.isoweekday() == 7: # Sunday!
sundayfound += 1
# print ("Sunday! #", sundayfound)
if (sundayfound == 2):
return checkday
return 99

today = date.today()
print("Today is: ", today)
currentyear = today.year

Yearseq = ""
Mothersdayseq = ""

print("If you were born on May",mybirthday)
lastyear = 0
for checkyear in range(mybirthyear-50, mybirthyear+100):
# print("Mothersday in", checkyear, "is on", checkdate)
Mothersday = DayofMothersday(checkyear)
if (Mothersday == 99):
print("Something has gone wrong!")
else:
if (Mothersdayseq == ""):
Mothersdayseq = str(Mothersday)
else:
Mothersdayseq = Mothersdayseq + "," + str(Mothersday)
if (Mothersday == mybirthday):
if (checkyear < mybirthyear):
timestring = "would have been"
elif (checkyear < currentyear):
timestring = "was"
elif  (checkyear > currentyear):
timestring = "will be"
else:
timestring = "is"
if (checkyear == mybirthyear):
print("In",  checkyear, "you were born on Mothersday! ")
else:
print("In",  checkyear, "your birthday",timestring,"on Mothersday! ")
if (lastyear > 0):
Yeardiff = (checkyear - lastyear)
if (Yearseq == ""):
Yearseq = str(Yeardiff)
else:
Yearseq = Yearseq + "," + str(Yeardiff)
lastyear = checkyear

print("Sequence =",Yearseq,"years inbetween.")
print("Mothersday sequence =",Mothersdayseq,".")
print ("done!")