Question
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:
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: 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
April is 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 F is: 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started