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 statement that can be used in Python if a statement is required syntactically but the program requires no action?

0 Answers  


What are “special” methods in python?

0 Answers  


What is raw_input?

0 Answers  


Which are the file related libraries/modules in python?

0 Answers  


What are some common uses of Pickling in Python?

0 Answers  






How are phon blocks defined?

0 Answers  


Is ruby better than python?

0 Answers  


What is a floating point in python?

0 Answers  


Which method removes and returns last object of a list?

0 Answers  


Is set ordered in python?

0 Answers  


What are python slots?

0 Answers  


Explain about classes in strings?

0 Answers  


Categories