0% found this document useful (0 votes)
61 views

Dict Python

A dictionary in Python is a data structure that stores key-value pairs, with keys being unique and values changeable. Dictionaries have methods like get(), update(), fromkeys(), keys(), values(), items(), pop(), popitem(), and copy() to interact with and retrieve data from the key-value pairs. The document provides examples of some common dictionary methods in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Dict Python

A dictionary in Python is a data structure that stores key-value pairs, with keys being unique and values changeable. Dictionaries have methods like get(), update(), fromkeys(), keys(), values(), items(), pop(), popitem(), and copy() to interact with and retrieve data from the key-value pairs. The document provides examples of some common dictionary methods in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

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

You might also like