Python hash() function

Published February 16, 2022

The hash() function in Python is a built-in function that returns an object's hash value. A hash value can be defined as the integer that can be used to quickly compare the dictionary keys when looking at the dictionary. Hash() produces irreversible hashed objects, which might result in data loss.

 

Syntax

The hash() function has the following syntax:

hash(object to convert into hash)

Example of how hash() works

var = ('P','Y','T','H','O','N')
print(hash(var))

Output

Python hash() function

 

 

Download Source code

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

257 Views