The hash()
method returns the hash value of an object in Python.
The syntax of this function is as follows:
hash(object)
The hash()
function takes one mandatory parameter, which is the object whose hash value is required.
The return value is an integer indicating the hash value of the specified object.
In the example below, the hash()
method is used to generate the has hash values of a string, integer, decimal number, and a set.
# hash value for stringprint('The hash for Educative is:', hash('Educative'))# hash value for integerprint('The hash for 470 is:', hash(181))# hash value for decimal numbersprint('The hash for 156.2 is:',hash(181.23))# hash value for listprint('The hash for (1,2,3) is:', hash((1,2,3)))