In this Calendar Module problem, we need to develop a python program that can read an integer input as a date and then can use the calendar module from python and print the day on that date on the output screen.

HackerRank Calendar Module solution in python


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())