Question

In: Computer Science

USE PYTHON ONLY Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day...

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.

Solutions

Expert Solution

//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


Related Solutions

Use Java (Science: day of the week) Zeller’s congruence is an algorithm developed by Christian Zeller...
Use Java (Science: day of the week) 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,...
PYTHON: Implement the following algorithm to construct magic n × n squares; it works only if...
PYTHON: Implement the following algorithm to construct magic n × n squares; it works only if n is odd. row ← n - 1 column ← n/2 for k = 1 . . . n2 do Place k at [row][column] Increment row and column if the row or column is n then replace it with 0 end if if the element at [row][column] has already been filled then Set row and column to their previous values Decrement row end if...
We also discussed the use of the Extended Euclidian algorithm to calculate modular inverses. Use this...
We also discussed the use of the Extended Euclidian algorithm to calculate modular inverses. Use this algorithm to compute the following values. Show all of the steps involved. 9570-1(mod 12935) 550-1 (mod 1769)
The use of social media as a marketing tool is only suitable for developed countries. It...
The use of social media as a marketing tool is only suitable for developed countries. It is not an effective tool for businesses in Small Island Developing States (SIDS) such as the Caribbean.” provide detail point agreeing with the statement and disagreeing with the statement.
Python we need to create a game using only the library graphic.py and use only Structure...
Python we need to create a game using only the library graphic.py and use only Structure Functions only.
USE PYTHON to find out What day of the week is a given date? i.e. On...
USE PYTHON to find out What day of the week is a given date? i.e. On what day of the week was 5 August 1967? if it is given that 1 January 1900 was a tuesday Write a function is_leap() which takes 1 input argument, an integer representing a year, and returns True if the year was a leap year, and False if it was not. .Then, write a function days_since() which takes 3 input integers day, month, year, representing...
1. Implement the recursive LU factorization algorithm in Python. Use plenty of comments to explain your...
1. Implement the recursive LU factorization algorithm in Python. Use plenty of comments to explain your code. While you are coding, it is helpful to break up your code into sub-functions and test the sub-functions as you go along.
Implement the recursive LU factorization algorithm in Python. Use plenty of comments to explain your code....
Implement the recursive LU factorization algorithm in Python. Use plenty of comments to explain your code. While you are coding, it is helpful to break up your code into sub-functions and test the sub-functions as you go along.
Writ a Python Program that illustrate the DES algorithm 1-Not allowed to use any crypto libraries...
Writ a Python Program that illustrate the DES algorithm 1-Not allowed to use any crypto libraries 2- The whole algorithm must be implemented from scratch 2- The code must be properly commented Please don’t use librae’s or any code on the internet please do the code for me i have posted this many times
Writ a Python Program that illustrate the DES algorithm 1-Not allowed to use any crypto libraries...
Writ a Python Program that illustrate the DES algorithm 1-Not allowed to use any crypto libraries 2- The whole algorithm must be implemented from scratch 2- The code must be properly commented Please don’t use librae’s or any code on the internet
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT