- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions

# Python program to find hash from a given tuple

Suppose we have a tuple. There are few numbers are present. We have to find the hash value of this tuple by using hash() function. This is a built-in function. The hash() function can work on some datatypes like int, float, string, tuples etc, but some types like lists are not hashable. As lists are mutable in nature, we cannot hash it. This hash value is used to map other values when we use dictionary.

So, if the input is like t = (2,4,5,6,7,8), then the output will be -1970127882925375109

To solve this, we will follow these steps −

take the tuple as input

call hash function and pass the tuple into it hash(tuple)

## Example

Let us see the following implementation to get better understanding

def solve(t): return hash(t) t = (2,4,5,6,7,8) print(solve(t))

## Input

(2,4,5,6,7,8)

## Output

-6569923111468529526

- Related Articles
- Python program to Find the size of a Tuple
- Python Program to create a Tuple using tuple literal
- Python Program to find the largest element in a tuple
- Program to find a good string from a given string in Python
- Python program to get first and last elements from a tuple
- Program to find folded list from a given linked list in Python
- Program to find nth smallest number from a given matrix in Python
- How we can create a dictionary from a given tuple in Python?
- Program to find tuple with same product in Python
- Program to find largest binary search subtree from a given tree in Python
- Python Program to add elements to a Tuple
- Python Program to print elements of a tuple
- Python Program to Sort a Tuple By Values
- Python Program to Replace Elements in a Tuple
- Program to find length of longest Fibonacci subsequence from a given list in Python

Advertisements