Python Program to Display Calendar

Python program to print calendars; In this tutorial, you will learn how to print or display calendars in the python program.

Python Program to Display Calendar

  • Python program to print the calendar of a given month and year
  • Python program to print calendar of any year

Python program to print the calendar of a given month and year

Follow the following steps and write python program to print the calendar of a given month and year:

  • Take input year/month from the user.
  • After that, call the month function.
  • Print the calendar of given month and year.
# Python program to print Calendar using
# Python Calender module

import calendar

# take year from user
year = int(input("Enter Year: "))

# take month from user
month = int(input("Enter Month: "))

# printing Calendar
print(calendar.month(year, month))

Output

Enter Year:  2020
Enter Month:  04

     April 2020
Mo Tu We Th Fr Sa Su
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

Python program to print calendar of any year

Follow the following steps and write python program to print the whole year calendar:

  • Take input year from the user.
  • Set the day of calendar.
  • After that, call the year function.
  • Print the calendar of the given year.
# Python program to print Calendar using
# Python Calender module

import calendar

# take year from user
year = int(input("Enter Year: "))

cal = calendar.TextCalendar(calendar.MONDAY)
# year: 2022, column width: 2, lines per week: 1
# number of spaces between month columns: 1
# 3: no. of months per column.
print(cal.formatyear(year, 2, 1, 1, 3))

Output

Enter Year:  2020
                              2020

      January               February               March
Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
       1  2  3  4  5                  1  2                     1
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   2  3  4  5  6  7  8
13 14 15 16 17 18 19  10 11 12 13 14 15 16   9 10 11 12 13 14 15
20 21 22 23 24 25 26  17 18 19 20 21 22 23  16 17 18 19 20 21 22
27 28 29 30 31        24 25 26 27 28 29     23 24 25 26 27 28 29
                                            30 31

       April                  May                   June
Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
       1  2  3  4  5               1  2  3   1  2  3  4  5  6  7
 6  7  8  9 10 11 12   4  5  6  7  8  9 10   8  9 10 11 12 13 14
13 14 15 16 17 18 19  11 12 13 14 15 16 17  15 16 17 18 19 20 21
20 21 22 23 24 25 26  18 19 20 21 22 23 24  22 23 24 25 26 27 28
27 28 29 30           25 26 27 28 29 30 31  29 30

        July                 August              September
Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
       1  2  3  4  5                  1  2      1  2  3  4  5  6
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   7  8  9 10 11 12 13
13 14 15 16 17 18 19  10 11 12 13 14 15 16  14 15 16 17 18 19 20
20 21 22 23 24 25 26  17 18 19 20 21 22 23  21 22 23 24 25 26 27
27 28 29 30 31        24 25 26 27 28 29 30  28 29 30
                      31

      October               November              December
Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
          1  2  3  4                     1      1  2  3  4  5  6
 5  6  7  8  9 10 11   2  3  4  5  6  7  8   7  8  9 10 11 12 13
12 13 14 15 16 17 18   9 10 11 12 13 14 15  14 15 16 17 18 19 20
19 20 21 22 23 24 25  16 17 18 19 20 21 22  21 22 23 24 25 26 27
26 27 28 29 30 31     23 24 25 26 27 28 29  28 29 30 31
                      30

 

Recommended Python Programs

  1. Python Program to Find/Calculate Average of 3, 4, 5…n numbers
  2. Python Program to Print ASCII Value of Character
  3. Write a Program to Calculate Simple Interest in Python
  4. Python Program to Compute Compound Interest
  5. Leap Year Program in Python
  6. Python Program to Print Star Pattern
  7. Number Pattern Programs in Python
  8. Python Program to Print Even and Odd numbers From 1 to N
  9. Python Abs() Function: For Absolute Value
  10. How to Check Whether a Number is Fibonacci or Not in Python
  11. Python: Program to Find Power of Number
  12. Python Program to Reverse a Numbers
  13. Python Program to Find Smallest/Minimum of n Numbers
  14. Python Program to Find Largest/Maximum of n Numbers
  15. Python Program to Find The Net Bill Amount After Discount
  16. Python Program to Print Numbers From N to 1 and 1 to N
  17. Python Program to Print Numbers Divisible by 3, 5, 7
  18. Python Program to Print Prime Number 1 to N
  19. How to Find Square of Number in Python
  20. Python Program to Calculate Cube of Number
  21. Python Program to Find LCM of Two Numbers
  22. BMI (Body Mass Index) Calculator in Python
  23. Palindrome Program in Python using while loop, Function, etc
  24. Python: Program to Count Total Number of Bits in Number
  25. Python Random Number Generator Code
  26. Python Program to Calculate n-th term of a Fibonacci Series
  27. Zip Zap Zoom Python Program
  28. Python: program to convert Celsius to Fahrenheit
  29. Python Program to Swap Two Numbers
  30. Python Program to Get Standard Deviation
  31. Python Program to Find the Variance
  32. Python Program to Convert Height in cm to Feet and Inches
  33. Python Program to Convert Meters into Yards, Yards into Meters
  34. Python Program to Convert Kilometers to Meters, Miles
  35. Python Program to Find Perfect Number
  36. Python: Program to Find Strong Number
  37. Python Program Create Basic Calculator
  38. Python Program For math.floor() Method
  39. Python Program to Print Alphabets from A to Z in Uppercase and Lowercase
  40. Python Program to Check Given Input is Alphabet, Number or Special Character
  41. Python Program to Check IF a Number is Power of Another Number
  42. Python Check Binary Representation of Given Number is Palindrome or Not
  43. Python Program to Draw a Pie Chart
  44. Python Program Input the Radius of Circle and Compute the Area
  45. Python Program to Calculate the Area of a Rectangle
  46. Python Program to Calculate Area of Triangle
  47. Python Program to Find Area and Circumference of Circle using Radius
  48. Python Program that Accepts Marks in 5 Subjects and Outputs Average Marks
  49. Python Program to Print Binary Value of Numbers From 1 to N

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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