Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. Write a simple Python program to find the day for the given date. The procedure to find the day of the week is as

image text in transcribedimage text in transcribed

5. Write a simple Python program to find the day for the given date. The procedure to find the day of the week is as follows: [25 Marks] F = (K+ (13 * m - 1) mod 5 +D+D mod 4 + C mod 4-2* C) mod 7 where, K: day of the month m: month number D: remainder when year divided by 100 C:quotient when year is divided by 100 Note: month is counted as follows: March is 1 Aprilis 2 January is 11 February is 12 So, the year starts from March and ends in February. So, if you have a month as January or February, then subtract 1 from the year. Example 1: if the entered date is 1st January 2000, then: K = 1 m = 11 D = (2000-1 ) mod 100 = 99 C = (2000 -1 ) quotient 100 = 19 F = (1 + (13* 11 - 1) mod 5 + 99 + 99 mod 4 + 19 mod 4-2 * 19 ) mod 7 = 6 If the value of Fis: 0 : Sunday 1: Monday 2: Tuesday 3: Wednesday 4: Thursday 5: Friday 6: Saturday So, the data 1st January 2000 is Saturday. Example 2: if the entered date is 1st April 1983, then: K= 1 m = 2 D = 1983 mod 100 = 83 C = 1983 quotient 100 = 19 F = (1 + (13*2-1) mod 5 + 83 + 83 mod 4 + 19 mod 4-2 * 19 ) mod 7 = 5 So, the data 1st April 1983 is Friday. Sample Test Data: Please enter the date: 2nd March, 2004 Sample Output: The day is Tuesday. 5. Write a simple Python program to find the day for the given date. The procedure to find the day of the week is as follows: [25 Marks] F = (K+ (13 * m - 1) mod 5 +D+D mod 4 + C mod 4-2* C) mod 7 where, K: day of the month m: month number D: remainder when year divided by 100 C:quotient when year is divided by 100 Note: month is counted as follows: March is 1 Aprilis 2 January is 11 February is 12 So, the year starts from March and ends in February. So, if you have a month as January or February, then subtract 1 from the year. Example 1: if the entered date is 1st January 2000, then: K = 1 m = 11 D = (2000-1 ) mod 100 = 99 C = (2000 -1 ) quotient 100 = 19 F = (1 + (13* 11 - 1) mod 5 + 99 + 99 mod 4 + 19 mod 4-2 * 19 ) mod 7 = 6 If the value of Fis: 0 : Sunday 1: Monday 2: Tuesday 3: Wednesday 4: Thursday 5: Friday 6: Saturday So, the data 1st January 2000 is Saturday. Example 2: if the entered date is 1st April 1983, then: K= 1 m = 2 D = 1983 mod 100 = 83 C = 1983 quotient 100 = 19 F = (1 + (13*2-1) mod 5 + 83 + 83 mod 4 + 19 mod 4-2 * 19 ) mod 7 = 5 So, the data 1st April 1983 is Friday. Sample Test Data: Please enter the date: 2nd March, 2004 Sample Output: The day is Tuesday

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

Step: 3

blur-text-image

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

2. What efforts are countries making to reverse the brain drain?

Answered: 1 week ago