Introduction
Setup
Operators
variable
String
Number
Dtype & Comment
Lists
Tuples
Sets
Dictionaries
if else statement
For Loop
While Loop
iterator & iterable
Pre-Built functions
Function
Decorators
generators
Types of errors
Exceptions Handling
OOP
Regular expression
Create module
OS module
Date module
Random module
Math
Statistics module
Exercise 1
Exercise 2
Exercise 3
Learn Data Structure & Algorithm
Learn Numpy
Learn Pandas
Learn Matplotlib
Learn Seaborn
Learn Statistics
Learn Math
Learn MATLAB
Learn Machine learning
Learn Github
Learn OpenCV
Learn Deep Learning
Learn MySQL
Learn MongoDB
Learn Web scraping
Learn Excel
Learn Power BI
Learn Tableau
Learn Docker
Learn Hadoop
Dictionary is used to store multiple collections of values in one variable. We can store too many value in a dictionary and perform a lot of work on it. Dictionary is unordered, changeable, and does not allow duplicates. We can store string, number, or both at the same time in a dictionary. We can use a capital letter and a small letter in a dictionary.
Dictionary is written inside the second bracket. So first give the name of the dictionary. We can't give space
between two words of a dictionary name. Then give an equal sign and then a second bracket{}.
Dictionary is used to store data values in key: value pairs.
For string must use single or double quotations (' '," ") and for numbers no need to use single or
double-quotes.
Give a comma between two values like (key: values, key: value).
Key means name of the value. If we want to access a single value from the dictionary then we have to call the
value by its key name. key name can't be double in a dictionary and to access the full dictionary, just call
the dictionary name.
In the example, x is the dictionary name. Name, Number, and topic are the key names and what we wrote in front of every key are the key values.
Example:2To get a specific values from a dictionary get() function is used.
Example:The keys function will make a list of all the keys present in the dictionary.
Example:values() function will make a list of all the values present in the dictionary.
Example:In the example we added two new keys which names are add_new_name_1, add_new_name_2. These two keys and values will be added at the end of the dictionary.
To update value of a dictionary update() function is used.
Example:In the example value of topic --> "learn python" is updated to learn python update .
To remove key and value from dictionary pop() function is used.
Example:popitem() function
To remove the last key and value from a dictionary popitem() function is used. If you use the popitem function one time then it will remove one value. Every time you do that, the value of the total will decrease from the end.
Example:1copy() function
To copy one dictionary to another dictionary copy() function is used.
Example: