![]() |
VOOZH | about |
In Python, dictionaries store data as key-value pairs. Tuples can be used as keys to represent multiple values, like coordinates or combinations, because they are immutable and hashable.
Let's consider an example where tuples are used as keys to store multiple numbers together:
A B
Explanation:
Let's consider an example where we use tuples as dictionary keys to store multiple numbers together, with each tuple mapping to a value.
First
Second
{(1, 2, 3): 'First', (4, 5, 6): 'Second'}
Explanation:
Let's consider a scenario where latitude and longitude are used as keys, and their corresponding place names are stored as values.
{("19.07'53.2", "72.54'51.0"): 'Mumbai', ("28.33'34.1", "77.06'16.6"): 'Delhi'}
["19.07'53.2", "28.33'34.1"]
["72.54'51.0", "77.06'16.6"]
['Mumbai', 'Delhi']
Explanation:
In this example, each key is a tuple containing three elements - an integer ID, first name, and last name, and each value is itself a nested dictionary with additional details.
geeks
for
geeks
{'b': 'marketing', 'c': 75000}
{'h': 35, 'i': 'project'}
Explanation: