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 |
You mentioned pypi in your previous answer. Can you elaborate?
What applications use python?
Explain “with” statement in python?
Is notepad ++ good for python?
What are the 3 types of relation?
What is pip and when it is used ?
How do I define raw_input in python?
How to print without newline or space?
Do you know how memory is managed in python?
Is set nesting implemented in python?
What is class variable in python?
Should I learn r or python first?