[go: up one dir, main page]

0% found this document useful (0 votes)
22 views2 pages

Difference Between List Jtuple Jdictionary and Set

The document describes four common Python data structures: lists, tuples, sets, and dictionaries. Lists and tuples store elements in ordered columns, while sets and dictionaries store elements in an unordered manner. Lists are mutable while tuples are immutable. Sets do not allow duplicate elements.

Uploaded by

Div Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Difference Between List Jtuple Jdictionary and Set

The document describes four common Python data structures: lists, tuples, sets, and dictionaries. Lists and tuples store elements in ordered columns, while sets and dictionaries store elements in an unordered manner. Lists are mutable while tuples are immutable. Sets do not allow duplicate elements.

Uploaded by

Div Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

List Tuple Set Dictionary

A list is a non- A Tuple is also a The set data


homogeneous non- structure is also A dictionary is
data structure homogeneous a non- also a non-
that stores the data structure that homogeneous homogeneous
elements in stores elements in data structure data structure
columns of a columns of a but stores the that stores key-
single row or single row or elements in a value pairs.
multiple rows. multiple rows. single row.

The dictionary
The list can be The set can be
Tuple can be can be
represented by represented by
represented by ( ) represented by {
[] {}
}

The list allows Tuple allows The Set will not The dictionary
duplicate duplicate allow duplicate doesn’t allow
elements elements elements duplicate keys.

The list can use The set can use The dictionary
Tuple can use
nested among nested among can use nested
nested among all
all all among all

Example: {1: “a”,


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

A setA
A list can be Tuple can be dictionary can A dictionary can
created using created using be created be created using
the list() functio the tuple() functio using the dict() functio
n n. the set() functio n.
n

A tuple is A set is
A list is mutable A dictionary is
immutable i.e we mutable i.e we
i.e we can make mutable, ut Keys
can not make any can make any
List Tuple Set Dictionary

any changes in changes in the changes in the are not


the list. tuple. set, ut elements duplicated.
are not
duplicated.

Dictionary is
Set is
List is ordered Tuple is ordered ordered (Python
unordered
3.7 and above)

Creating an Creating an empty Creating a set Creating an


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

You might also like