ADVERTISEMENT
ADVERTISEMENT

Python calendar Module | weekheader() Method with Example

Python calendar.weekheader() Method: Here, we are going to learn about the weekheader() method of calendar module in Python with its definition, syntax, and examples.
Submitted by Hritika Rajput, on May 08, 2020

Python calendar.weekheader() Method

weekheader() method is an inbuilt method of the calendar module in Python. It works on simple text calendars and returns a header containing the abbreviated names of the weekday.

Module:

    import calendar

Syntax:

    weekheader(n)

Parameter(s):

  • n: It is a required parameter, which represents the width in characters for one weekday.

Return value:

The return type of this method is <class 'str'> (a string), it returns a header containing abbreviated weekday names.

Example:

## Python program to illustrate the 
## use of weekheader() method
  
# importing calendar module 
import calendar 

n = 1
print("When width in character for one weekday = 1")
print(calendar.weekheader(n))
print()

n = 3
print("When width in character for one weekday = 3")
print(calendar.weekheader(n))
print()

n = 5
print("When width in character for one weekday = 5")
print(calendar.weekheader(n))
print()

n = 10
print("When width in character for one weekday = 10")
print(calendar.weekheader(n))
print()

n = 15
print("When width in character for one weekday = 15")
print(calendar.weekheader(n))

Output

When width in character for one weekday = 1
M T W T F S S

When width in character for one weekday = 3
Mon Tue Wed Thu Fri Sat Sun

When width in character for one weekday = 5
 Mon   Tue   Wed   Thu   Fri   Sat   Sun 

When width in character for one weekday = 10
  Monday    Tuesday   Wednesday   Thursday    Friday    Saturday    
  Sunday  

When width in character for one weekday = 15
     Monday         Tuesday        Wednesday        Thursday         
     Friday         Saturday         Sunday 
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.