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 |
Is python shell scripting?
What is the output of the following code and why?
Explain other string literals?
Explain what is Flask & its benefits?
What is dict when we have to use ?
Which python memory profiler is recommended?
Can you sort a string in python?
Why does python use self?
What is python interpreter?
How do you clear a python shell?
What is def __ init __ in python?
What exactly is SVM?