The calendar module allows you to output calendars and provides additional useful functions for them.
class calendar.TextCalendar([firstweekday])
This class can be used to generate plain text calendars.
Sample Code
>>> import calendar
>>>
>>> print calendar.TextCalendar(firstweekday=6).formatyear(2015)

Task
You are given a date. Your task is to find what the day is on that date.
Input Format
A single line of input containing the space separated month, day and year, respectively, in format.
Constraints
Output Format
Output the correct day in capital letters.
Sample Input
08 05 2015
Sample Output
WEDNESDAY
Explanation
The day on August th was WEDNESDAY.
weekday={0:'MONDAY',1:'TUESDAY',2:'WEDNESDAY',3:'THURSDAY',4:'FRIDAY',5:'SATURDAY',6:'SUNDAY'}import calendarm=[]a=list(input().split()) #MM DD YYYY formatday=(calendar.weekday(int(a[2]),int(a[0]),int(a[1]))) #gives input in year,month,day formatprint(weekday[day])
Calendar.weekday takes input in year,month,day format. So, we will give our input list a=[08,05,2015] in YYYY, MM, DD format to this function. In order to convert 08 to 8 and 05 to 5 we will typecast all values into int.
calendar.weekday -returns the day of the week in integer values where 0 is MONDAY and soon..
To print the day name we will make the use of dictionary weekday which we created earlier in the code.

0 comments:
Post a Comment
Feel free to share your thoughts and suggestion...