Python Data Structure and Containers

Python has several in built data containers to facilitate efficient data storage and retrieval. Some key ones are-

  • List
  • Tuple
  • Dictionary

Let’s look at the above types one by one

List- Lists are mutable (can be edited) and iterable data containers with homogeneous or heterogeneous data. This is one of the most commonly used data structure in Python. A list is denoted by square brackets – “ [ ]

Let’s look at some examples of lists operations-





Next, let’s do slicing and dicing of the list. This follows the same zero based indexing as strings




Tuple- Tuples operations are significantly faster than list, however tuples are immutable. Tuples are best suited for write once and read many times jobs such as big data operations. Similar to list, a tuple can store heterogeneous data.

They are defined by ” ( ) “.  Let’s look at some examples of tuples operations-


Dictionary- Similar to tuples operations, dictionary operations are significantly faster than that of lists. A dictionary is made of “Key-Value” combinations. Values are generally retrieved by providing the keys.

Dictionaries are defined by ” { } “.  Let’s look at some examples of dictionary operations-



You can find much more information on the above objects in Python Official Documentation.


One thought on “Python Data Structure and Containers

  1. Pingback: Learn Python Step by Step | RP's Blog on data science