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 would you define a block in python?
What is an abstract class in python?
What does echo do python?
What is difference between panda series and dictionary in python?
What is pip and pip freeze commands will do?
What is mro in python?
What do you know about the python enumerate?
Can we develop a web application using Python
Is python the future of programming?
What is the difference between numpy and scipy?
What is json? Describe in brief how you’d convert json data into python data?
What is the best code you can write to swap two numbers?