Calendar Module in Python - HackerRank Solution

Calendar Module - Python HackerRank Solution

Hello Friends, How are you? Today I am going to solve the HackerRank Calendar Module Problem in Python with a very easy explanation. In this article, you will get one or more approaches to solving this problem. So let's start-

{tocify} $title={Table of Contents}

Default Arguments Python HackerRank Solution

HackerRank Python Calendar Module Solution - Problem Statement

The calendar module allows you to output calendars and provides additional useful functions for them.


This class can be used to generate plain-text calendars.

Sample Code

>>> import calendar >>> >>> print calendar.TextCalendar(firstweekday=6).formatyear(2015) 2015 January February March Su 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 14 11 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21 18 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28 25 26 27 28 29 30 31 29 30 31 April May June Su 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 13 12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 31 July August September Su 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 12 12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19 19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26 26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 30 31 October November December Su 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 12 11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19 18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26 25 26 27 28 29 30 31 29 30 27 28 29 30 31 {codeBox}

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 0

08 05 2015 {codeBox}

Sample Output 0

WEDNESDAY {codeBox}

Explanation: 

The day on August 15th 2015 was Wednesday.

Python Calendar Module - Hacker Rank Solution

Approach I: Calendar Module HackerRank Python Solution

# ========================
#       Information
# ========================

# Name: Calendar Module in Python HackerRank
# Direct Link: https://www.hackerrank.com/challenges/calendar-module/problem
# Difficulty: Easy
# Max Score: 10
# Language: Pypy 3

# ========================
#         Solution Start
# ========================

#Calendar Module in Python - Hacker Rank Solution
   
# 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())
   
#Calendar Module in Python - Hacker Rank Solution END
# MyEduWaves


Disclaimer: The above Problem ( Python Calendar Module ) is generated by Hackerrank but the Solution is Provided by MyEduWaves. This tutorial is only for Educational and Learning purposes. Authority if any queries regarding this post or website fill out the contact form.

I hope you have understood the solution to this HackerRank Problem. All these three solutions will pass all the test cases. Now visit Python Calendar Module Hackerrank Problem and try to solve it again.

All the Best!

Post a Comment

Previous Post Next Post