Calendar Module in Python | HackerRank Solution

Hello coders, today we are going to solve Calendar Module in Python Hacker Rank Solution.

Calendar Module in Python

Objective

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.

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.

Solution – Calendar Module in Python – Hacker Rank Solution

Python 3

# Enter your code here. Read input from STDIN. Print output to STDOUT
import datetime
import calendar

m, d, y = map(int, input().split())
input_date = datetime.date(y, m, d)
print(calendar.day_name[input_date.weekday()].upper())

Disclaimer: The above Problem (Calendar Module in Python) is generated by Hacker Rank but the Solution is provided by CodingBroz. This tutorial is only for Educational and Learning purpose.

Leave a Comment

Your email address will not be published.