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 D. The second line is an integer N.
Output
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.
Sample Input 1
Monday
16
Sample Output 1
Tuesday
Sample Input 2
Tuesday
17
Sample Output 2
Thursday
first_day = input('first day ').title()
day = int(input('date '))
weekday = (
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday')
if first_day in weekday:
ind = weekday.index(first_day)
day = (day+ind-1)%7
print(weekday[day])
else:
print('incorrect first day')
Comments
Leave a comment