Lists, dictionary, Tuples and sets Flashcards
Differences between lists and Tuples
List is defined in [ ]
Tuples defined { }
Lists are mutable
Tuples are immutable
Can not assign value to tuple elements
similarities in List and Tuple
ordered collection of elements
can contain elements of different data types
elements are accessed using index values starting from zero
slicing operations can be done in both
Complex data Function
List tuple and dictionary
Sets
Duplicated not allowed
do not have order
Tuple can be part of set
elements in set immutable
sets do not have look up function
all values are unique
set does not support indexing
joining two sets- union function, duplicates removed
cannot contain mutable elements such as lists, dictionaries within sets
nested lists
list of list
one list nested within the other
slicing operation possible in nested lists
lists
python converts lists to dictionary
dictionary has -outermost list, middle list, innermost list
pop- works on outer most list
lists have look up function
Dictionary
unordered collection of key value pairs
every key is associated with a value
each key is unique, value can be duplicate
values are looked up by keys
mapping goes in one direction
mutable, keys can be added