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

Why do we use __ init __ in python?

564


What are the packages?

535


Tell us what is module and package in python?

574


What does map function in python do?

625


Is r similar to python?

570






What do you understand by monkey patching in python?

543


In python, how do I read a file line-by-line into a list?

586


Is python written in python?

567


Which statement of python is used whenever a statement is required syntactically but the program needs no action?

568


Tell me how are arguments passed by value or by reference?

524


What is step size in python?

594


How to send an email in python language?

607


How do we make forms in python?

650


Tell me what is pickling and unpickling?

559


When do you choose a list over a tuple?

580