PYTHON
I need some basic python homework help!
Write a program that prompts the user to enter a date (day, month, and year). Your program will print out the day of the week for that date.
You do not need to validate the input. That means you can assume:
Algorithm:
This algorithm is called "Zeller's Congruence" after the person who developed it, Rev. Christian Zeller.
Some sample calculations: for July 31, 1929, you should get a = 5, b = 31, c = 29, and d = 19. Similarly, for January 3, 1988, you should get a = 11, b = 3, c = 87, and d = 19.
Then calculate the following quantities:
w = (13 * a - 1 ) // 5
x = c // 4
y = d // 4
z = w + x + y + b + c - 2 * d
r = z % 7
r = (r + 7) % 7 [to take care of negative values of r]
If you did this correctly, r gives you the day of the week. r = 0 represents Sunday, r = 1 represents Monday, and so on.
#Zeller Congruence
def day(r):
return {
0 : "Sunday",
1 : "Monday",
2 : "Tuesday",
3 : "Wednesday",
4 : "Thursday",
5 : "Friday",
6 : "Saturday"
}[r]
month=input("Enter Month-")
date=int(input("Enter date-"))
year=int(input("Enter year-"))
monthValue = {'January': 11 , 'February':
12,'March':1,'April':2,'May':3,'June':4,'July':5,'August':6,'September':7,'October':8,'November':9,'December':10}
#python dictionary is created according to the value of
every month.
a=monthValue.get(month)
b=date
if month=='January' or month=='February':
year=year-1
c=year%100 #to get the last 2 digits of the
year
d=year//100 #to get the first 2 digits of the year
w=(13*a-1)//5
x=c//4
y=d//4
z=w+x+y+b+c-2*d
r=z%7
r=(r+7)%7
print(day (r)) # the value r is a integer to get the corresponding day of the week the above function day is created.

If you found this helpful please
upvote.
PYTHON I need some basic python homework help! Write a program that prompts the user to...
in python
Worth 5 points (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). - is the day of the month. m is the month (3: March, 4: April, ...,...
in python Write a program that reads the date of birth from the user as 3 integer values (day, month, year) and then computes and prints their exact age in days. You need to take into account the leap You may not use any built-in functions related to date and time! Example: Someone born on 01/01/2000 is 365 days * 18 years + 5 days (since the years 2000, 2004, 2008, 2012, and 2016 are all leap years) + 352...
Need help implementing this Java class (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 + 5 * j) % 7 where h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). q...
C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...
I need help with a project, I’ve seen many answers in C++, but
i need it to be in swift, thank you!
Write a program that asks the user to enter a date (e.g. July 4, 2008) and will return the day of the week that corresponds to that date. Your program should take the input in numeric form, thus the input prompt should be as follows: Please enter a date below: Enter month (1-12): Enter day (1-31) Enter year...
1. Write a Python program that will determine if the user can vote or not. The program will ask the user to enter integer numbers that represent year, month, and day of birth. Also, the program will ask the user to enter the current year, current month, and current day. The program will determine if the user is allowed to vote or not. If the user age is greater than or equal 18 then the program will print the following...
Write a python program that does the following. a. It asks the user to enter a 5-digit integer value, n. b. The program reads a value entered by the user. If the value is not in the right range, the program should terminate. c. The program calculates and stores the 5 individual digits of n. d. The program outputs a “bar code” made of 5 lines of stars that represent the digits of the number n. For example, the following...
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...
USING PYTHON. (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, 4: April, ...,...
PYTHON Build a regular expressions based on informal specifications to match specified patterns. Use a compiled regular expression in a Python program where appropriate. Use Python's text processing str methods to generate a string format converter. create a date format converter. Your program will convert a date in the format “mm/dd/yyyy” to the format “month day, year”. Specify the required input format: mm/dd/yyyy Use a regular expression to validate the user input date format. If the format is incorrect raise...