Explain the dictionary in Python.
Answer / chaitanya
Python's built-in data type is dictionary, which defines one-to-one relationships between keys and values.
Dictionaries consist of pairs of keys and their corresponding values.
Dictionaries are indexed by keys.
Dictionary is similar to associative array or hash table of other languages.
As following example explains further- India, Angel & Cartoon are keys & their corresponding values are Bharat, Mother Teresa & Mickey respectively.
>>> dict = {'India': 'Bharat', 'Angel': ‘Mother Teresa’, 'Cartoon': 'Mickey'}
>>>print dict[India]
Bharat
>>>print dict[Angel]
Mother Teresa
| Is This Answer Correct ? | 2 Yes | 0 No |
What do you mean by instance?
How Python performs Compile-time and Run-time code checking?
What does netflix use python for?
How long do goats sleep?
What is dogpile mechanism? Explain.
What is the shortest method to open a text file and display its content?
Explain identity operators in python?
Does python have oops concepts?
Is python good for oop?
Is python time time utc?
How does break, continue and pass work?
Is there a way to remove the last object from a list?