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 does while 1 mean in python?
Explain docstring in python?
Explain garbage collection in python?
How to copy an object in python?
What is a metaclass in Python?
What does == mean in python?
What is map, filter and reduce in python?
What is a documentation string?
Is python faster than python2?
Explain me what is the statement that can be used in python if the program requires no action but requires it syntactically?
What is a lambda form?
Explain about different blocks in exception handling?