Lists Flashcards

1
Q

Lunghezza lista L

A

len(L)

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

return element at an index in list L

A

L[i]

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

return last element at an index in list L (2 modi)

A

L[ len(L) -1]

L[-1]

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

return the index of a specific value xxx in list L

A

L.index(xxx)

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

check if an element xxx is in the list L (boolean)

A

xxx in L

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

iterate over a list L (get a list of all the values in all the indexes)

A

for i in L:

print (i)

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

access nested element (in index 0, nested in a sublist placed at index 1 of list L)

A

L [1] [0]

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

length of sublist placed at index 1 of list L

A

len( L [1] )

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

subset list: create a list L2 containing a list with two elements extracted from index 2 of L

A

L2=L [2 ]

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

ranges (of subset) to subset in list L2 from list L : starting to end, indefinite starting to end; starting to indefinite end

A
L2= L [x : y]
L2= L [... : y]
L2= L [x : ...]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

operazioni con elementi della lista L (somma di elementi in index 0 e 1)

A

xxx=L [0] + L[ 1]

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