Friday the thirteenth is generally seen as an unlucky day in our culture. However, it is not immediately clear where this superstition comes from. Although there are numerous reports in various religions and customs, it seems this superstition is at most 100 years old.

The combination of the weekday Friday and the number thirteen is also not as universal as you might think. In Belgium, the Netherlands and England, for example, Friday the thirteenth is indeed seen as an unlucky day. However, in Greece, Spain and Latin America, Tuesday the thirteenth is an unlucky day. In Italy everyone is extra careful on Friday the seventeenth.
Write a function unlucky_days that takes a starting date (datetime.date) for its first parameter start_date.
The function also has an optional second parameter end_date that may take an end date (datetime.date). If no value is explicitly passed to the end_date parameter, the function must use today as the end date.
The function also has an optional third parameter day that may take a day number (int). If no value is explicitly passed to the day parameter, the function must use 13 as the day number.
The function also has an optional fourth parameter weekday that may take a weekday number (int). If no value is explicitly passed to the weekday parameter, the function must use Friday as the weekday.
The function must return the number of days (int) between the start date and the end date (including boundaries) that fall on the given day and weekday. If the start date is more recent than the end date, there are no days between the start date and the end date, and the function must logically return the value 0.
In this assignment, you have to make use of the data types date and timedelta that are defined in the datetime module of the Python Standard Library. Before starting to work on the assignment, you should first have a look at how Python responds when you execute the following instructions in an interactive Python session:
>>> from datetime import date
>>> birthday = date(1983, 1, 14)
>>> d = date.today() - birthday
>>> type(d)
>>> d.days
>>> from datetime import timedelta
>>> birthday + timedelta(1)
>>> day1 = birthday + timedelta(1)
>>> day1
>>> day2 = day1 + timedelta(1)
>>> day2
>>> today = date.today()
>>> today
>>> today.weekday()
>>> tomorrow = today + timedelta(1)
>>> tomorrow.weekday()
>>> tomorrow.day
Make sure that you understand why the different results are generated.
>>> from datetime import date >>> unlucky_days(date(2012, 1, 1), date(2012, 12, 31)) 3 >>> unlucky_days(date(2012, 1, 1), date(2012, 12, 31), 14, 5) 3 >>> unlucky_days(date(2012, 1, 1), date(2012, 12, 31), 17, 4) 2 >>> unlucky_days(date(2012, 1, 1), date(2012, 12, 31), 13, 1) 2 >>> unlucky_days(start_date=date(2012, 1, 1), day=1, weekday=0, end_date=date(2012, 12, 31)) 1
Famous people born on Friday the 13th:
Tupac Shakur died on Friday the 13th.
Composer Arnold Schoenberg was fascinated with numerology. Born on Sept. 13, he came to fear that he would die at age 76, because its digits add to 13. He examined a calendar for 1951 and was dismayed to see that July 13 fell on a Friday. When the fateful day came he took to his bed, fearing the worst. The day passed uneventfully, and shortly before midnight his wife entered the bedroom to say goodnight. Schoenberg uttered the word "harmony" and died.
The time of his death was 11:47 p.m., 13 minutes before midnight on Friday, July 13, in his 76th year.
It's estimated that, in the United States alone, businesses lose $800 million to $900 million each Friday the 13th because some people will not travel or go to work. The fear of this date is called paraskavedekatriaphobia.