Python Cheatsheet
Python Cheatsheet
CHEAT SHEET
FOR PYTHON
DATA STRUCTURES
THE
CHEAT SHEET
FOR PYTHON
DATA STRUCTURES
Python Data
Structures
Built-in User-defined
Data Structures Data Structures
Changeable
the data can be removed, added, or changed
Ordered
the data order is defined and unchanged
Duplicates
it can contain data of the same values
Dictionary
for storing values in the
key-value pairs
Changeable
the data can be removed, added, or changed
Ordered
the data order is defined and unchanged
No Duplicates
it can't contain data of the same values
Set
for storing multiple items
in a single variable
Unchangeable
the data can't be removed, added, or
changed after creating the set
Unordered
the data order is not defined and will change Tuple
with every use of the list
for storing multiple items
No Duplicates in a single variable
it can’t contain data of the same values
Unchangeable
the data can't be removed, added, or
changed after creating the set
Ordered
the data order is defined
and unchanged
Duplicates
it can contain data of the same values
Stack
for storing and retrieving data sequentially,
e.g., as temporary storage of data within procedures
Queue
for storing and retrieving data sequentially,
e.g., as a control of access to shared resources
Two children
each node has a maximum of two children (left and right)
Randomness
nodes are stored randomly in the memory
Hash Map
for storing the data through the key-value pair and making data
insertion, deletion, update, and retrieval quicker
Key-value pair
assigns each element a key-value pair
Graph
for storing and retrieving data sequentially in the form of nodes that contain
its data and the address of the following node, e.g., dynamic memory allocation
Randomness
nodes are stored randomly in the memory
Gives a descriptive name to each position in the tuple
namedtuple()
and is used for accessing values instead of indices.
@stratascratch
STRATASCRATCH
www.stratascratch.com