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
Python
program 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
Python
program in the fileeastersunday.py
that 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
year
is the variable for the year in question. In the provided code,year
takes on the value2001
. - Your program must perform the following calculations:
- Divide
year
by19
and call the remaindera
. Ignore the quotient. - Divide
year
by100
to get a quotientb
and a remainderc
. - Divide
b
by4
to get a quotientd
and a remaindere
. - Divide
(8 * b + 13)
by25
to get a quotientg
. Ignore the remainder. - Divide
(19 * a + b - d - g + 15)
by30
to get a remainderh
. Ignore the quotient. - Divide
c
by4
to get a quotientj
and a remainderk
. - Divide
(a + 11 * h)
by319
to get a quotientm
. Ignore the remainder. - Divide
(2 * e + 2 * j - k - h + m + 32)
by7
to get a remainderr
. Ignore the quotient. - Divide
(h - m + r + 90)
by25
to get a quotientn
. Ignore the remainder. - Divide
(h - m + r + n + 19)
by32
to get a remainderp
. Ignore the quotient.
- Divide
- The result is that Easter Sunday falls on day:
p
of the month:n
. - For example, given the year
2001
, we find that the result is:n = 4
andp = 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.py
to execute thePyUnit
test bench.PyUnit
indicates a successful test with anOK
output, and an unsuccessful test with aFAIL
output.
Submission
- Upload the file
eastersunday.py
to the Web-CAT automated grading platform.