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.
The first line is a string
The output should be a string.
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
dayNames= ['Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
d= input("Enter first day of the month: ")
num = int(input('Enter an integer: '))
i = num%7 -1
if d in dayNames:
j = dayNames.index(d)+i
if j >= 7:
j = j - 7
print(dayNames[j])
Comments
Leave a comment