[5625 views]
If you will ask a programmer then he will tell that python is his favorite programming language. Who would not like to code in a few lines? It is free and open-source along with easy to learn and use features. There are many applications of python including machine learning, data science, development of APIs and so on. In this article, you will learn about the inbuilt data structure in python
Python has four built-in data structures- lists, dictionary, tuple, and sets.
It contains an ordered sequence of items. This data structure is mutable and non-scalar i.e you can change items by adding or removing. As lists are built-in, so, there is no need for creating them. It can be used regardless of the type of object. The elements are stored in a square bracket separated with commas. Lists in python look similar to C arrays in the python interpreter and it works like an array of pointers.
It is like lists containing an ordered sequence of elements but this data structure isn’t mutable. You can’t change elements. Elements must be in parenthesis separated with commas. It has a fixed length because of immutable nature.
A dictionary consists of keys(name) and values (details). Make sure while choosing a key that it’s unique. In this data structure, keys can be immutable but we can use both immutable and mutable objects for values.
It refers to the collection of simple and unique objects but in an unordered manner. Sets are used when an object in a collection matters more than its order. Elements of a set must contain an immutable data type.
Knowing these data structure will help you at many situations while programming. It is the basic of python programming that we want you to know.