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 |
What does netflix use python for?
What is the difference between numpy and scipy?
What is raw_input?
What is difference between sort and sorted in python?
What is the use of dictionary in python?
What opens a py file?
What is python explain the advantages of using python?
Why python is called python?
Name a few methods that are used to implement functionally oriented programming in python?
What is __ doc __ in python?
Mention what are the rules for local and global variables in Python?
Why and when do you use generators in python?