You are on page 1of 1

List Tuple Set Dictionary

List is a non- Tuple is also a non- Set data structure is Dictionary is also a non-
homogeneous homogeneous data also non- homogeneous data
data structure that structure that stores homogeneous data structure which stores key
stores the single row and structure but stores value pairs
elements in single multiple rows and in single row
row and multiple columns
rows and columns

List can be Tuple can be Set can be Dictionary can be


represented by represented by represented by represented by { }
[] {}
()

List allows Tuple allows Set will not allow Dictionary doesn’t allow
duplicate duplicate elements duplicate elements duplicate keys.
elements

List can use Tuple can use Set can use nested Dictionary can use nested
nested among all nested among all among all among all

Example: Example: Example: Example:


[1, 2, 3, 4, 5] (1, 2, 3, 4, 5) {1, 2, 3, 4, 5} {1: “a”, 2: “b”, 3: “c”, 4: “d”,
5: “e”}

List can be Tuple can be Set can be created Dictionary can be created
created created using set() using dict() function.
using list() using tuple() function
function function.

List is mutable i.e Tuple is immutable Set is mutable i.e we Dictionary is mutable. But
we can make any i.e we can not make can make any Keys are not duplicated.
changes in list. any changes in tuple changes in set. But
elements are not
duplicated.

List is ordered Tuple is ordered Set is unordered Dictionary is ordered


(Python 3.7 and above)

Creating an empty Creating an empty Creating a set Creating an empty


list Tuple dictionary
a=set()
l=[] t=() d={}
b=set(a)

You might also like