can you show me how to answer this on sypder using python as a calculator (zellers congruence) 1(i) On what day of the week is Yorkshire Day next year (1st August 2024)? (ii) Charles Babbage was born on 26 December 1791. What day of the week was that?
can you show me how to answer this on sypder using python as a calculator (zellers congruence)
1(i) On what day of the week is Yorkshire Day next year (1st August 2024)?
(ii) Charles Babbage was born on 26 December 1791. What day of the week was that?
1. Start
2. Define the function `day_of_week(year, month, day)`:
- If `month` is less than 3, increment `month` by 12 and decrement `year` by 1.
- Calculate `K` as the last two digits of `year`.
- Calculate `J` as the first two digits of `year`.
- Calculate `day_of_week` using Zeller's Congruence formula:
- `(day + 13 * (month + 1) // 5 + K + K // 4 + J // 4 - 2 * J) % 7`
- Map the result to the corresponding day of the week using a list of days.
3. Calculate the day of the week for Yorkshire Day on 1st August 2024:
- Set `year_1` to 2024, `month_1` to 8, and `day_1` to 1.
- Call the `day_of_week` function with `year_1`, `month_1`, and `day_1` as arguments.
- Display the result.
4. Calculate the day of the week for Charles Babbage's birthday on 26th December 1791:
- Set `year_2` to 1791, `month_2` to 12, and `day_2` to 26.
- Call the `day_of_week` function with `year_2`, `month_2`, and `day_2` as arguments.
- Display the result.
5. End.
Step by step
Solved in 4 steps with 2 images