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?
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')
Get Answers For Free
Most questions answered within 1 hours.