Python hash() function
Python hash() function
The hash() function in Python returns the hash value of the object (if it has one).
Syntax
hash(object)
Parameter
obj : This parameter represents the object which we need to convert into hash.
Return
This function returns the hashed value.
Example 1
# Python Program explaining # the hash() function # initializing the objects int_val = 14 str_val = 'Hello World' flt_val = 24.56 print ("The integer hash value returns: " + str(hash(int_val))) print ("The string hash value returns: " + str(hash(str_val))) print ("The float hash value returns: " + str(hash(flt_val)))
Output
The integer hash value returns: 14 The string hash value returns: 420554245396003518 The float hash value returns: 1291272085159665688