Questions

How do I Print a whole Year Calendar in Python?

If one wants to print a whole year calendar as output, the user must enter a valid year as the input, and using the calendar module in Python, one can simply print the calendar for that respective year. 

Follow the steps given below:

  • The first step is to import the calendar module 
  • Initialize the year you desire
  • The year is taken via the module’s built-in function calendar().
  • Use the calendar to print the calendar for a specific year. calendar(year)

                    

Source Code:

import calendar //import the calendar module

def printcalendar(yr):


     # printing calendar

     print(calendar.calendar(yr))
  

# driver program

yr = 2019

printcalendar(yr)

Output:

The whole calendar year of 2019 will be displayed as the output.

Related Questions

Related Topics

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.