In: Computer Science
USE PYTHON ONLY
Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is
h = (q + 26(m+1)//10 + k + k//4 +j//4 +5j) % 7
where
- h is the day of the week (0: Saturday, 1: Sunday, 2: Monday,
3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday).
- q is the day of the month.
- m is the month (3: March, 4: April, ..., 12: December). January
and February are counted as months 13 and 14 of the previous
year.
- j is year//100.
- k is the year of the century (i.e., year % 100).
Write a program that prompts the user to enter a year, month, and day of the month, and then it displays the name of the day of the week.
//Python program
def dayofweek(d, mon, y):
if (mon == 1) :
mon = 13
y = y - 1
if (mon == 2) :
mon = 14
y = y - 1
q = d
m = mon
k = y % 100
j = y // 100
h = q + 13 * (m + 1) // 5 + k + k // 4 + j // 4 + 5 * j
return h % 7
# Driver Code
d = int(input("Enter day : "))
m = int(input("Enter month : "))
y = int(input("Enter year : "))
day = dayofweek(d,m,y)
week =
["Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"]
print("Week day : ",end="")
print(week[day])
//screenshot