Answer to Question #221106 in Python for Dr Kiran Tummalapa

Question #221106

Day Name - 2

Given the weekday of the first day of the month, determine the day of the week of the given date in that month.

Input

The first line is a string

D. The second line is an integer N.Output

The output should be a string.

Explanation

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.So, the output should be

Tuesday.


1
Expert's answer
2021-07-29T23:33:44-0400
day_names= ['Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
D= input("Enter first day of the month: ")
N = int(input('Enter an integer: '))
i = N%7 -1 
if D in day_names:
    j = day_names.index(D)+i
    if j >= 7:
        j = j - 7
    print(day_names[j])

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