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 is python package manager (pypm)?
How lists is differentiated from tuples?
Please explain when is the python decorator used?
Do you need classes in python?
How will you merge two dictionaries in python?
What is a closure in python?
Write a program to convert all strings in list to integers?
What is a lambda function?
Is it necessary to know c to learn python?
What are the two modes of python?
What is the syntax for dictionary comprehension in python?
What is static in python?