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 pip and pip freeze commands will do?

0 Answers  


Is null in python?

0 Answers  


please give the code for these 1 2 4 7 11 16...

1 Answers  


What is meshgrid in python?

0 Answers  


Do they know a tuple/list/dict when they see it?

0 Answers  






Difference between pass and continue in python?

0 Answers  


What do you understand by python iterator and iterable elements?

0 Answers  


Name different types of inheritance in python?

0 Answers  


How does a function return values?

0 Answers  


Which library would you prefer for plotting in python language: seaborn or matplotlib?

0 Answers  


How do I use python idle?

0 Answers  


post me some questions from pythom script

1 Answers   Infosys,


Categories