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 def __ init __ in python?

0 Answers  


What sort does python use?

0 Answers  


How do you sort a dataframe in descending order?

0 Answers  


What is Flask and explain its benefits?

2 Answers  


What is proxy object in python?

0 Answers  






Is python dict a hashmap?

0 Answers  


What is a cast in python?

0 Answers  


What is flatmap in python?

0 Answers  


What are the 3 types of relation?

0 Answers  


Is it easy to learn python?

0 Answers  


Why Lambda is used in Python?

1 Answers  


How do you debug a python program?

0 Answers  


Categories