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 |
How to find bugs or perform static analysis in a python application?
What is a numpy in python?
Tell me what are different methods to copy an object in python?
Is python a programming language?
What is the output of the below program?
What is python console?
Tell us what is module and package in python?
What is difference between input and raw_input in python?
How to get indices of n maximum values in a numpy array?
Is python a high level language?
What are Python's built-in data structures?
How can the ternary operators be used in python?