Dictionary in Python

Dictionary in Python:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) Dictionary is an unordered collection of key-value pairs. It is generally used to operate on a huge amount of data. Dictionaries are optimized for retrieving data. We must know the key to retrieve the value. Dictionary key can be of almost any Python type but usually numbers or strings. Values, on the other hand, can be any arbitrary python object dictionaries enclosed by curly braces { }. The values are assigned and accessed by using square brackets [ ]. Dictionaries are mutable which implies that the contents of the dictionary can be changed after it has been created.

(2) Example of Python Dictionary:

  • Create Dictionary in Python as shown below.
creation of dictionary in python
  • Access value from the Dictionary by the use of a key as shown below.
Access value from the Dictionary in python
  • Iteration in Python Dictionary as shown below.

To get keys.

to get keys in python dictionary

To get values.

to get values from dictionary in python

MySQL Inner Join
MySQL Left Join and Right Join
Natural Language Processing (NLP)
What is Virtual Reality?
Operating System as a Resource Manager
Multimedia and Its Application
Python (programming language)– Wikipedia

Comments (No)

Leave a Reply