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 will be the output of ['!!welcome!!']*2?

1 Answers  


How do I run python on windows?

1 Answers  


Define flask in python?

1 Answers  


How does python handle compile-time and run-time code checking?

1 Answers  


How do you handle exceptions in Python?

2 Answers  


If while installing a package with pip, you get the error no matching installation found, what can you do?

1 Answers  


Python documentation is called?

1 Answers  


What is class super?

1 Answers  


How do you sort in python 3?

1 Answers  


What is index out of range error?

1 Answers  


What is the difference between a function and a method python?

1 Answers  


How to send an email in python language?

1 Answers  


Categories