A hash is an fixed sized integer that identifies a particular value.
hash(object) : Returns hash value of the input object ( if available )
Hashable and Immutable
hash() value is available for immutable objects ( what is immutable and mutable object ?), but all Hashable are not immutable.

print(hash(300))        # 300 
print(hash(300.56))     #1291272085159674156
print(hash('plus2net')) #-4778224534751702784
hash value of tuple
print(hash(my_tuple))      # 7654376616106661247
hash value of list
print(hash(my_list)) # Error
Above code will generate error
 TypeError: unhashable type: 'list'
hash() value of user defined object
class student_kit():
    college_name='ABC College'  #class attributes

     #instance attributes
    def __init__(self,name,section):
        self.name= name
        self.height=5  #instance attribute

Alex=student_kit('Alex','A')  # object declaration

print(hash(Alex))  # -9223371866271725652

All Built in Functions in Python
id() Mutable & Immutable object Bitwise operators using hash() int() float()

Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net


    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2023 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer