hash()

hash(object) : Returns hash value of the input object ( if available )

hash() value is available for immutable objects ( what is immutable and mutable object ?)
print(hash(300))        # 300 
print(hash(300.56))     #1291272085159674156
print(hash('plus2net')) #-4778224534751702784
hash value of tuple
my_tuple=('Alex','Ronald','John')
print(hash(my_tuple))      # 7654376616106661247
hash value of list
my_list=['Alex','Ronald','John']
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.section=section
        self.height=5  #instance attribute

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

print(hash(Alex))  # -9223371866271725652

All Built in Functions in Python
max() Bitwise operators using hash() int() float()



plus2net.com



Post your comments , suggestion , error , requirements etc here




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