Explain the dictionary in Python.

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

How to generate all permutations of a list in python?

495


Explain about multi-threading concept in python?

459


What is file context manager?

483


What is the length of your largest python code? Can you please describe the project?

501


What is abc abstractmethod?

464






What does r in a circle mean?

440


How do you create a database in python?

443


What are advantages of a tuple over a list?

469


Is anaconda the same as python?

434


How is python different from java?

493


How will you uit the python?

478


What is the cost of python certification?

441


Is python too slow?

539


What is docstring in Python?

541


What do you mean by ‘suites’ in python?

492