Python Notes
Python Notes
Python Notes
Lists: are just like dynamic sized arrays, declared in other languages (vector in C+
+ and ArrayList in Java). Lists need not be homogeneous always which makes it the
most powerful tool in Python. unlike lists that are mutable.
Tuple: A Tuple is a collection of Python objects separated by commas. In some
ways, a tuple is similar to a list in terms of indexing, nested objects, and repetition
but a tuple is immutable(Cannot be changed).
Set: A Set is an unordered collection data type that is iterable, mutable, and has no
duplicate elements. Python’s set class represents the mathematical notion of a set.
Dictionary: in Python is an ordered (since Py 3.7) [unordered (Py 3.6 & prior)]
collection of data values, used to store data values like a map, which, unlike other
Data Types that hold only a single value as an element, Dictionary
holds key:value pair. Key-value is provided in the dictionary to make it more
optimized.
List, Tuple, Set, and Dictionary are the data structures in python that are used to
store and organize the data in an efficient manner.
List is a non-
homogeneous Tuple is also a non- Set data structure
Dictionary is also a
data structure that homogeneous data is also non-
non-homogeneous
stores the structure that stores homogeneous
data structure
elements in single row and data structure but
which stores key
single row and multiple rows and stores in single
value pairs
multiple rows columns row
and columns
Tuple can be
List can be represented by Set can be Dictionary can be
represented by [ ] represented by { } represented by { }
()
List can use Tuple can use nested Set can use nested Dictionary can use
nested among all among all among all nested among all
Dictionary is
List is ordered Tuple is ordered Set is unordered ordered (Python 3.7
and above)
Below is the program for implementation of List, tuple, set, and dictionary:
Dictionary:
Used to create a data frame with lists
Used in JSON