Explain the dictionary in Python.



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

Post New Answer

More Python Interview Questions

Is python shell scripting?

0 Answers  


What is the output of the following code and why?

0 Answers  


Explain other string literals?

0 Answers  


Explain what is Flask & its benefits?

0 Answers  


What is dict when we have to use ?

0 Answers  


Which python memory profiler is recommended?

0 Answers  


Can you sort a string in python?

0 Answers  


Why does python use self?

0 Answers  


What is python interpreter?

0 Answers  


How do you clear a python shell?

0 Answers  


What is def __ init __ in python?

0 Answers  


What exactly is SVM?

2 Answers  


Categories