{"id":26026,"date":"2021-12-14T08:43:03","date_gmt":"2021-12-14T03:13:03","guid":{"rendered":"https:\/\/python-programs.com\/?p=26026"},"modified":"2021-12-14T08:43:03","modified_gmt":"2021-12-14T03:13:03","slug":"python-program-for-calendar-setfirstweekday-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-calendar-setfirstweekday-method-with-examples\/","title":{"rendered":"Python Program for calendar setfirstweekday() Method with Examples"},"content":{"rendered":"
Calendar Module:<\/strong><\/p>\n The calendar module allows you to output calendars like a program and includes extra calendar-related operations. Calendar module functions and classes make use of an idealized calendar, the current Gregorian calendar extended in both directions indefinitely.<\/p>\n setfirstweekday() Method:<\/strong><\/p>\n calendar.setfirstweekday(weekday) is a function in Python’s calendar module for creating simple text calendars.<\/p>\n The setfirstweekday() method sets the weekday (0 is Monday, 6 is Sunday) to start each week. Syntax:<\/strong><\/p>\n Parameter Values: <\/strong>This method has no parameters.<\/p>\n Return Value:<\/strong> None<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n
\nThe values MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, and SUNDAY are provided for convenience.<\/p>\nsetfirstweekday()<\/pre>\n
Program for calendar setfirstweekday() Method with Examples in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Import calendar module using the import keyword.\r\nimport calendar\r\n# Set the day as SUNDAY, and pass it as an argument to the setfirstweekday() function\r\n# Store it in a variable.\r\nrslt_calndr = calendar.setfirstweekday(calendar.SUNDAY)\r\n# Print the above result.\r\nprint(rslt_calndr)\r\n<\/pre>\n