Lists, dictionary, Tuples and sets Flashcards

1
Q

Differences between lists and Tuples

A

List is defined in [ ]
Tuples defined { }

Lists are mutable
Tuples are immutable

Can not assign value to tuple elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

similarities in List and Tuple

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Complex data Function

A

List tuple and dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Sets

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

nested lists

A

list of list

one list nested within the other

slicing operation possible in nested lists

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

lists

A

python converts lists to dictionary

dictionary has -outermost list, middle list, innermost list

pop- works on outer most list

lists have look up function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Dictionary

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly