Python has multiple data structures like Lists, Tuples, Dictionaries, Sets, and more . Some of them are Ordered and some are Unordered. This article will discuss Ordered Vs Unordered Data Structures in Python. Lists It is a collection of a mutable ordered sequence of elements and can be accessed through indexing and defined inside []. Each element inside a List is called an item. From the above example, it is clear that the list maintains a sequence in which elements are inserted. So, it is an ordered data structure in python. Tuples It is a collection of immutable ordered elements, which follows a sequence in which elements are inserted. It is defined inside () and accessed through indexing. The above example shows that Tuples are ordered data structure and follow the sequence of insertion. Dictionaries Collection of items, in which items are defined as key-value pair in {}. Dictionaries are ordered data structures in python. It can be accessed through a specific key. E...
Robotics, IoT, Embedded System & Coding
Comments
Post a Comment