Lab 2: Easter Sunday
Web-CAT: Submit Python programs to this automated grading platform.
Background
- Due Date: Thursday, September 12, 2019
- Total Points: 10
- In this lab, you must write a
Pythonprogram that determines which particular day and month that Easter Sunday appears.
Code Distribution
| Description | File Size | File Name |
|---|---|---|
Python Source Code for Easter Sunday |
1.2KB | lab02.zip |
Contents of lab02.zip:
Lab02EasterSunday/
├── eastersunday.py
└── testeastersunday.py
Specification
- Write a
Pythonprogram in the fileeastersunday.pythat computes the date of Easter Sunday, given a particular year. Easter Sunday is a holiday which falls on the first Sunday after the first full moon of Spring. This algorithm was discovered by Carl Friedrich Gauss. - The parameter
yearis the variable for the year in question. In the provided code,yeartakes on the value2001. - Your program must perform the following calculations:
- Divide
yearby19and call the remaindera. Ignore the quotient. - Divide
yearby100to get a quotientband a remainderc. - Divide
bby4to get a quotientdand a remaindere. - Divide
(8 * b + 13)by25to get a quotientg. Ignore the remainder. - Divide
(19 * a + b - d - g + 15)by30to get a remainderh. Ignore the quotient. - Divide
cby4to get a quotientjand a remainderk. - Divide
(a + 11 * h)by319to get a quotientm. Ignore the remainder. - Divide
(2 * e + 2 * j - k - h + m + 32)by7to get a remainderr. Ignore the quotient. - Divide
(h - m + r + 90)by25to get a quotientn. Ignore the remainder. - Divide
(h - m + r + n + 19)by32to get a remainderp. Ignore the quotient.
- Divide
- The result is that Easter Sunday falls on day:
pof the month:n. - For example, given the year
2001, we find that the result is:n = 4andp = 15. This means that Easter Sunday was on April 15 in the year 2001. - You will write your solution in a function called
retrievedate(year), right below the place where it says:YOUR CODE HERE.
Testing
- Run the file
testeastersunday.pyto execute thePyUnittest bench.PyUnitindicates a successful test with anOKoutput, and an unsuccessful test with aFAILoutput.
Submission
- Upload the file
eastersunday.pyto the Web-CAT automated grading platform.