Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Zeller's Congruence in Python. Build a series of code on Python. 1. Add 9 to the month, take the remainder upon division by 12, and

Zeller's Congruence in Python. Build a series of code on Python.

1. Add 9 to the month, take the remainder upon division by 12, and add 4. This is the adjusted month. (As a result, the adjusted month is 4 for March, 5 for April, 13 for December, 14 for January, and 15 for February.) 2. Subtract the adjusted month divided by 14 from the year. This is the adjusted year. (The effect is to subtract 1 from the year if it's January or February.) 3. Take the adjusted year divided by 100. This is the century. (The century is the first two digits of the adjusted year.) 4. Take the remainder that the adjusted year leaves upon division by 100. This is the century year. (The century year is the last two digits of the adjusted year.) 5. Multiply the adjusted month by 26, and divide by 10. This is the month correction. (I can't explain this step; it's just... magic.) 6. Add the following values: The day, the month correction, the century year, the century year divided by 4, the century divided by 4, and 5 times the century. 7. Add 6 to the result in step 6, and take the remainder upon division by 7. This is the day of the week, with 0 denoting Sunday, 1 Monday, etc.

For example, if we use today's date, January 13, 2020, we get the following calculation: 1. What Day Were You Born?

1. adjusted month = (1+9)%12+4 = 10 + 4 = 14. 2. adjusted year = 2020-14//14 = 2020-1=2019. 3. century = 2019//100 = 20. 4. century year = 2019%100 = 19. 5. month correction = (26 x 14)//10 = 364//10 = 36. 6. Add: 13 + 36 + 19 + 19//4 + 20//4 + 5 x 20 =177. 7. (177+6)%7 = 183%7 = 1, which stands for Monday. Which is right!

8. Lastly, be able to convert integer to days of the week. (0=Sunday, 1=Monday, 2=Tuesday...etc)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions