Question

d = int(input('Enter the date: ')) m = int(input('Enter the month: ')) y = int(input('Enter the...

d = int(input('Enter the date: '))
m = int(input('Enter the month: '))
y = int(input('Enter the year: '))

if m<3:
m = m + 12
y = y - 1
a = (2*m) + (6*(m+1)/10)
b = y + (y/4) + (y/400) - (y/100)
c = d + a + b + 1
f = c / 7

if f == 0:
print ('Sunday')
elif f == 1:
print ('Monday')
elif f == 2:
print ('Tuesday')
elif f ==3:
print ('Wednesday')
elif f == 4:
print ('Thursday')
elif f == 5:
print ('Friday')
else:
print ('Saturday')

i have written this code but i cannot seem not get the right answer i only get saturday as a result. how can i fix it?

Homework Answers

Answer #1

d = int(input('Enter the date: '))

m = int(input('Enter the month: '))

y = int(input('Enter the year: '))

if m<3:

m = m + 12

y = y - 1

a = (2*m) + (6*(m+1)//10)

b = y + (y//4) + (y//400) - (y//100)

c = d + a + b + 1

f = c % 7

if f == 0:

print ('Sunday')

elif f == 1:

print ('Monday')

elif f == 2:

print ('Tuesday')

elif f ==3:

print ('Wednesday')

elif f == 4:

print ('Thursday')

elif f == 5:

print ('Friday')

else:

print ('Saturday')

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The National Highway Traffic Safety Administration reported the percentage of traffic accidents occurring each day of...
The National Highway Traffic Safety Administration reported the percentage of traffic accidents occurring each day of the week. Assume that a sample of 420 accidents provided the following data. Sunday Monday Tuesday Wednesday Thursday Friday Saturday 69 47 54 49 58 69 74 a. Conduct a hypothesis test to determine if the proportion of traffic accidents is the same for each day of the week. What is the p-value? Compute the value of the X2 test statistic (to 3 decimals)....
Refactor the following program to use ArrayList instead of Arrays. You can google "Java ArrayList" or...
Refactor the following program to use ArrayList instead of Arrays. You can google "Java ArrayList" or start with the link below: https://www.thoughtco.com/using-the-arraylist-2034204 import java.util.Scanner; public class DaysOfWeeks { public static void main(String[] args) { String DAY_OF_WEEKS[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; char ch; int n; Scanner scanner = new Scanner(System.in); do { System.out.print("Enter the day of the Week: "); n = scanner.nextInt() - 1; if (n >= 0 && n <= 6) System.out.println("The day of the week is " + DAY_OF_WEEKS[n] + ".");...
So, the brewery selected it’s place and now needs to hire folks. After some testing, they...
So, the brewery selected it’s place and now needs to hire folks. After some testing, they expect to have approximately 2,000 customers per week. Since they will be open 7 days a week, they need to hire people to help serve their beer. They know that Friday and Saturday will drive sales. Between these 2 days, they will get 50% of their weekly sales. So, Friday has 25% of sales and Saturday has 25% of the sales. As for Sunday...
CODE BLOCK D flag = 0 while flag == 0 : guess = input ("Select an...
CODE BLOCK D flag = 0 while flag == 0 : guess = input ("Select an option:\n1. Add a course\n2. Drop a course\n3. Print your registration.\n4. Quit\n\n>>> ") if guess.isdigit() : guess = int(guess) if guess == 1: print("Lets add a course") elif guess == 2: print("Lets drop a course") elif guess == 3: print("Lets print your registration") elif guess == 4: print("Bye") flag = 1 else: print(“Huh?”) If the user enters the value 5. What will print?
Days of the week Write a program that asks the user for a number in the...
Days of the week Write a program that asks the user for a number in the range of 1 through 7. The program should display the corresponding day of the week, where 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. The program should display an error message if the user enters a number that is outside of the range of 1 though 7.
Write a function num_day that takes a number in the range of 1 through 7 as...
Write a function num_day that takes a number in the range of 1 through 7 as a parameter and returns a string representing the corresponding day of the week, where 1=Monday, 2 =Tuesday, 3= Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. The function should return the string "Error" if the parameter is that is outside the range of 1 through 7. You may assume that the parameter will be only numbers. Save the...
convert the while loop into for loop x = int(input('Enter initial value: ')) count = 0...
convert the while loop into for loop x = int(input('Enter initial value: ')) count = 0 if(x<1): print('Error') exit() print('Initial value is: ',x,' ',end='') while(x!=1): if(x%2==0): x=x/2 else: x=3*x+1 count+=1 if(x!=1): rint('Next value is: ',int(x),' ',end='') else: print('Final value ',int(x),', ',end='') print('number of operations performed ',int(count),' ',end='') break
PHP Question: _____________________________________________ Write the PHP code to list out all of the dates of the...
PHP Question: _____________________________________________ Write the PHP code to list out all of the dates of the current month and assign them to their given days. As an example, for the month of October 2020, the output should look something like this: October 2020       Monday: 5, 12, 19, 26 Tuesday: 6, 13, 20, 27 Wednesday: 7, 14, 21, 28 Thursday: 1, 8, 15, 22, 29 Friday: 2, 9, 16, 23, 30 Saturday: 3, 10, 17, 24, 31 Sunday: 4,...
USE PYTHON ONLY PLEASE Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the...
USE PYTHON ONLY PLEASE 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...
A personnel manager is concerned about absenteeism.  She decides to sample the records to determine if absenteeism...
A personnel manager is concerned about absenteeism.  She decides to sample the records to determine if absenteeism is distributed evenly throughout the six-day workweek.  The null hypothesis to be tested is: Absenteeism is distributed evenly throughout the week.  The 0.01 level is to be used.  The sample results are: Day f week Number Absent Monday 12 Tuesday 9 Wednesday 11 Thursday 10 Friday 9 Saturday 9 What is the calculated chi-square value?                A)  1.0   B)   0.5     C)   0.8 D)  8.0 I know the answer is C...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT