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

What is the output of this below query?

0 Answers  


What is pip command in python?

0 Answers  


What are the two modes of python?

0 Answers  


How manages to python handle memory management?

0 Answers  


How do you write a function in python 3?

0 Answers  






What is instance of a class?

0 Answers  


What does the function zip() do?

0 Answers  


What is the output for the following code?

0 Answers  


What are the types of inheritance in python?

0 Answers  


What is setup py?

0 Answers  


What is whitespace in python?

0 Answers  


Does python have access specifiers?

0 Answers  


Categories