1
PYTHON
3
DICT
5
METHODS
7
10
In Python - a Dictionary is a data structure
used to store values in the form of key:value
pairs
Items are Ordered (they exist in a defined
order), and Changeable (they can be altered,
adding, removed after creation)
Dicts do not allow duplicate keys (but different
keys could have the same associated value)
There are many important methods that can
be used with Dictionaries...
1
5
.get()
6 Returns the value associated
with a specified key
7
10
1
5
.update()
6 Updates your dictionary with a
new key:value pair
7
10
1
5
.fromkeys()
6 Creates/Returns a dictionary
based upon pre-specified keys &
7
values
8
10
1
5
.keys()
6 Returns all of the keys from your
dictionary
7
10
1
5
.values()
6 Returns all of the values from
your dictionary
7
10
1
5
.items()
6 Returns all of the key:value pairs
from your dictionary (each
7
returned as a tuple)
8
10
1
5
.pop()
6 Removes (and returns) the key
and value for a specified key
7
10
1
5
.popitem()
6 Removes (and returns) the most
recently added key:value pair
7
10
1
5
.copy()
6 Returns a copy of your dictionary
7
10
1
5
.clear()
6 Removes all elements of your
dictionary
7
10
Want to land an
incredible role in the
exciting, future-proof,
and lucrative field of
Data Science?
"I had over 40 interviews without an offer.
After DSI I quickly got 7 offers including one
at KPMG and my amazing new role at
Deloitte!" - Ritesh
"The best program I've been a part of, hands
down"
- Christian
"DSI is incredible - everything is taught in
such a clear and simple way, even the more
complex concepts!"
- Arianna
>> https://data-science-infinity.teachable.com