Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I saw an example of code where a hash function is applied to the tuple. As a result, it returns a negative integer. I wonder what does this function do. Google does not help. I found a page that explains how the hash is calculated but it does not explain why we need this function.

1 Answer

0 votes
by (106k points)

In Python, a hash is a fixed-sized integer that identifies a particular value. Each value needs to have its own hash, so for the same value, you will get the same hash even if it's not the same object.

>>> hash("Look at me!") 

4343814758193556824 

>>> f = "Look at me!" 

>>> hash(f) 

4343814758193556824

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Oct 29, 2019 in Java by Anvi (10.2k points)
0 votes
2 answers
asked Jul 12, 2019 in Java by Aditya98 (1.3k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...