Differences
between list’s,
tuples and set’s
, LIST TUPLE SET
Definition: In ➢ Definition: In ➢ Definition: In
Python, a list is a Python, a tuple is a Python, a set is an
collection of items collection of items unordered
that are ordered. It that are ordered. It collection of
is defined using is defined using unique items. It is
square brackets [], parentheses (), defined using curly
with individual with individual braces {}, with
items separated by items separated by individual items
commas. commas. separated by
Properties: Properties: commas.
➢ Mutable: Lists are ➢ Immutable: Tuples Properties:
mutable, which are immutable, ➢ Unordered: Sets
means that we can which means their are unordered,
add, remove, or contents cannot be meaning that the
modify items after changed once they order of their
the list has been are created. This is elements is not
created. different from lists, guaranteed.
➢ Ordered: Lists are which are mutable.
➢ Unique elements:
ordered, which ➢ Ordered: Tuples
Sets contain only
means that the maintain the order
unique elements,
items in the list of their elements.
This means that meaning that
have a specific
the first element of there can be no
order. We can
the tuple will duplicates.
access individual ➢ Mutable: Sets are
always be the first
items in a list using
element, the mutable, meaning
their index, which
second element that you can add
starts at 0. We can will always be the or remove
also use slicing to second element, elements after the
extract a portion and so on. set is created.
of the list. ➢ Indexable: Tuples ➢ Iterable: Sets are
➢ Heterogeneous: can be accessed iterable, which
Lists can contain using indexing. means we can use
any combination This means that a loop to iterate
of data types, you can retrieve a over all their
including integers, specific element of
elements.
floats, strings, a tuple by
➢ Hashable: Sets are
Booleans, and hashable, which
between list’s,
tuples and set’s
, LIST TUPLE SET
Definition: In ➢ Definition: In ➢ Definition: In
Python, a list is a Python, a tuple is a Python, a set is an
collection of items collection of items unordered
that are ordered. It that are ordered. It collection of
is defined using is defined using unique items. It is
square brackets [], parentheses (), defined using curly
with individual with individual braces {}, with
items separated by items separated by individual items
commas. commas. separated by
Properties: Properties: commas.
➢ Mutable: Lists are ➢ Immutable: Tuples Properties:
mutable, which are immutable, ➢ Unordered: Sets
means that we can which means their are unordered,
add, remove, or contents cannot be meaning that the
modify items after changed once they order of their
the list has been are created. This is elements is not
created. different from lists, guaranteed.
➢ Ordered: Lists are which are mutable.
➢ Unique elements:
ordered, which ➢ Ordered: Tuples
Sets contain only
means that the maintain the order
unique elements,
items in the list of their elements.
This means that meaning that
have a specific
the first element of there can be no
order. We can
the tuple will duplicates.
access individual ➢ Mutable: Sets are
always be the first
items in a list using
element, the mutable, meaning
their index, which
second element that you can add
starts at 0. We can will always be the or remove
also use slicing to second element, elements after the
extract a portion and so on. set is created.
of the list. ➢ Indexable: Tuples ➢ Iterable: Sets are
➢ Heterogeneous: can be accessed iterable, which
Lists can contain using indexing. means we can use
any combination This means that a loop to iterate
of data types, you can retrieve a over all their
including integers, specific element of
elements.
floats, strings, a tuple by
➢ Hashable: Sets are
Booleans, and hashable, which