Problem
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) 2015 January February MarchSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7 4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 1411 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 2118 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 2825 26 27 28 29 30 31 29 30 31 April May JuneSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 1 2 1 2 3 4 5 6 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 1312 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 2019 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 2726 27 28 29 30 24 25 26 27 28 29 30 28 29 30 31 July August SeptemberSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 1 1 2 3 4 5 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 1212 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 1919 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 2626 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 30 31 October November DecemberSu Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 1211 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 1918 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 2625 26 27 28 29 30 31 29 30 27 28 29 30 31
To learn more about different calendar functions, click here.
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 MM DD YYYY format.
Constraints
2000 < year < 3000
Output Format
Output the correct day in capital letters.
Sample Input
08 05 2015
Sample Output
WEDNESDAY
Explanation
The day on August 5th 2015 was WEDNESDAY
.
In this problem, we are to print out the specific day the given date on calendar, in capital letters.
Solution to HackerRank Calendar Module in Python
import calendard = list(map(int, input().split()))week_day = ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]print(week_day[calendar.weekday(d[2], d[0], d[1])])
Comments
Post a Comment