In this HackerRank Calendar Module problem solution in python, The calendar module allows you to output calendars and provides additional useful functions for them.
You are given a date. Your task is to find what the day is on that date.
>
Problem solution in Python 2 programming.
import calendar MM, DD, YYYY = map(int,raw_input().split()) print calendar.day_name[calendar.weekday(YYYY,MM,DD)].upper()
Problem solution in Python 3 programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT import calendar #calendar.Calendar(calendar.SUNDAY) user_input = input().split() month = int(user_input[0]) day = int(user_input[1]) year = int(user_input[2]) c = calendar.weekday(year, month, day) if c == 0: print("MONDAY") elif c == 1: print("TUESDAY") elif c == 2: print("WEDNESDAY") elif c==3: print("THURSDAY") elif c==4: print("FRIDAY") elif c== 5: print("SATURDAY") elif c==6: print("SUNDAY")
Problem solution in pypy programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT import calendar m, d, y = map(int, raw_input().split()) print list(calendar.day_name)[calendar.weekday(y, m, d)].upper()
Problem solution in pypy3 programming.
from datetime import datetime import calendar date_str = input() date = datetime.strptime(date_str, '%m %d %Y') print ('{}'.format(calendar.day_name[date.weekday()]).upper())