Function Details: hash

Description


Returns the hash value of the object (if it has one).


Extended Description


The hash() function returns the hash value of an object if it has one. Hash values are integers used to quickly compare dictionary keys during a dictionary lookup. Numeric values that compare equal have the same hash value (even if they are of different types, as is the case for 1 and 1.0).


Read More about hash from Python Documentation

Function Signature


hash(object: Any) -> int

Module: builtins

Parameters



Parameter List


  • object: Any

Return


Returns an integer hash value for the object. The return value is guaranteed to be the same within the same Python session for objects that are not modified.


Return Type


int

Output

Explanation

This example shows how hash() can be used with different types of hashable objects.