Python calendar prcal() Method with Example

Python calendar.prcal() Method: In this tutorial, we will learn about the prcal() method of calendar module in Python with its usage, syntax, and examples. By Hritika Rajput Last updated : April 24, 2023

Python calendar.prcal() Method

The calendar.prcal() method is an inbuilt method of the calendar module, it is used to print the calendar of the specific year. Also, there is no need for a print operation to execute this.

Module

The following module is required to use prcal() method:

import calendar

Syntax

The following is the syntax of prcal() method:

prcal(year, w=0, l=0, c=6, m=3)

Parameter(s)

The following are the parameter(s):

  • year: It is a required parameter, which represents the year of the calendar
  • w: It is an optional parameter, which specifies the width of the date column
  • l: It is an optional argument, which represents the number of lines each week in the calendar will use.
  • c: It is an optional parameter, which specifies number of spaces between month columns
  • m: It is an optional parameter, which represents the number of column of months in a row

Return Value

The return type of this method is <class 'NoneType'>, it does not return any value; it only prints the calendar of the given year.

Example of calendar.prcal() Method in Python

# Python program to illustrate the 
# use of prcal() method

# importing calendar module
import calendar

print("Printing 2020 calendar using default parameters")
calendar.prcal(2020)
print()

print("Printing 2001 calendar with w=2, l=2")
calendar.prcal(2001, 2, 2)
print()

print("printing 2020 calendar with w=1,l=1,c=2,m=4")
# this includes 4 months in one row
calendar.prcal(2020, 1, 1, 2, 4)

Output

Printing 2020 calendar using default parameters
                                  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

Printing 2001 calendar with w=2, l=2
                                  2001



      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  6  7                1  2  3  4                1  2  3  4

 8  9 10 11 12 13 14       5  6  7  8  9 10 11       5  6  7  8  9 10 11

15 16 17 18 19 20 21      12 13 14 15 16 17 18      12 13 14 15 16 17 18

22 23 24 25 26 27 28      19 20 21 22 23 24 25      19 20 21 22 23 24 25

29 30 31                  26 27 28                  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          1  2  3  4  5  6                   1  2  3

 2  3  4  5  6  7  8       7  8  9 10 11 12 13       4  5  6  7  8  9 10

 9 10 11 12 13 14 15      14 15 16 17 18 19 20      11 12 13 14 15 16 17

16 17 18 19 20 21 22      21 22 23 24 25 26 27      18 19 20 21 22 23 24

23 24 25 26 27 28 29      28 29 30 31               25 26 27 28 29 30

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             1  2  3  4  5                      1  2

 2  3  4  5  6  7  8       6  7  8  9 10 11 12       3  4  5  6  7  8  9

 9 10 11 12 13 14 15      13 14 15 16 17 18 19      10 11 12 13 14 15 16

16 17 18 19 20 21 22      20 21 22 23 24 25 26      17 18 19 20 21 22 23

23 24 25 26 27 28 29      27 28 29 30 31            24 25 26 27 28 29 30

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  5  6  7                1  2  3  4                      1  2

 8  9 10 11 12 13 14       5  6  7  8  9 10 11       3  4  5  6  7  8  9

15 16 17 18 19 20 21      12 13 14 15 16 17 18      10 11 12 13 14 15 16

22 23 24 25 26 27 28      19 20 21 22 23 24 25      17 18 19 20 21 22 23

29 30 31                  26 27 28 29 30            24 25 26 27 28 29 30

                                                    31


printing 2020 calendar with w=1,l=1,c=2,m=4
                                         2020

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

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

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



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.