Home » Python » Python Reference » Python date Class

# Python date weekday() Method with Example

**Python date.weekday() Method**: Here, we are going to learn about the **weekday() method of date class in Python** with its definition, syntax, and examples.

Submitted by Hritika Rajput, on April 29, 2020

## Python date.weekday() Method

**date.weekday() method** is used to manipulate objects of date class of module datetime.

It uses a date class object and returns the day of the week as an integer, where Monday is 0 and Sunday is 6. It is an instance method.

**Module:**

import datetime

**Class:**

from datetime import date

**Syntax:**

weekday()

**Return value:**

The return type of this method is a number which tells us what is the day of the week on that day.

**Example:**

## importing date class from datetime import date ## Creating an instance x = date.today() d = x.weekday() print("Today's weekday number is:", d) x = date(2020, 10, 30) d1 = x.weekday() print("Weekday number on the date",x,"will be:",d1) print() ## Since we know the number, ## we can save them in a list and ## print the day on that number day =["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] print("Today's day is:",day[d]) print("Day on date", x," will be:", day[d1])

**Output**

Today's weekday number is: 2 Weekday number on the date 2020-10-30 will be: 4 Today's day is: Wednesday Day on date 2020-10-30 will be: Friday

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions