Python Data Structure- Part 1

Prachi Agrawal
Analytics Vidhya
Published in
2 min readFeb 13, 2021

Python is a modern, easy-to-learn, object-oriented programming language. It has a powerful set of built-in data types. If you are new to python language, then this blog is will help you learn. This blog contains basic linear data structure of python.

  1. List: It is a linear data structure in Python that is a mutable, or changeable, ordered sequence of elements. They are heterogeneous, meaning that the data objects need not all be from the same class and the collection can be assigned to a variable.

eg: List=[1,2,3,’a’,True]

Operation performed on the list:

2. Tuple: They are very similar to lists in that they are heterogeneous sequences of data. The difference is that a tuple is immutable, like a string. A tuple cannot be changed. Operations performed on tuple are same as that of the list except the assignment operation as we cannot change items in the tuple.

eg: Tuple = (2,True,4.96)

3. Sets: A set is an unordered collection of zero or more immutable Python data objects. Sets do not allow duplicates and are written as comma-delimited values enclosed in curly braces. The empty set is represented by set(). Sets are heterogeneous, and the collection can be assigned to a variable.

eg: set={1,2,3,’a’,True}

Operation performed on the set:

4. Dictionary: Dictionaries are collections of associated pairs of items where each pair consists of a key and a value. This key-value pair is typically written as key: value. It is unordered structure.

eg: dicti={1:’a’;2:’b’:3:’c’}

Operation performed on the dictionary:

5. String: They are sequential collections of zero or more letters, numbers and other symbols. We call these letters, numbers and other symbols characters.

eg: s=’abcbd’

Operation performed on string:

Hope you find this article helpful. Watch out for an upcoming article, I’ll be writing about other data structure in Python. Until then, keep learning!

--

--