Answer to Question #237991 in Python for balu

Question #237991

In the given example,

D = Monday. As the 1st of the day of the month is a Monday, it means the 7th and 14th of the month will be Sundays (A week has 7 days). So the 16th day (N = 16) of the month will be a Tuesday.

determine day of the week of the given date and month


1
Expert's answer
2021-09-16T06:09:13-0400
weekNames = ['Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
D = input()
N = int(input())
i = N%7 -1 
if D in weekNames:
    dayIndex = weekNames.index(D)+i
    if dayIndex >= 7:
        dayIndex -= 7
    print(weekNames[dayIndex])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS