lists Flashcards

1
Q

list_name.append(x)

A

add item to the end of the list

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

list_name[x]

A

access value at index x

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

list_name[x] = y

A

assign y value to index x

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

list_name.insert(x, y)

A

insert value y at index x

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

del list_name[x]

A

delete value at index x

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

list_name.pop() or list_name.pop(x)

A

remove an item from the end of the list

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

list_name.remove(x)

A

remove the first occurrence an item by value instead of by index

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

list_name.sort()

A

sort items in a list permanently

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

list_name.sort(reverse=True)

A

reverse the sort order

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

list_name.sorted()

A

lets you display your list in a particular order but doesn’t affect the actual order of the list

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

list_name.reverse()

A

reverse order of items in list

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

len(list)

A

returns length (number of items) in the list

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

list_name[-1]

A

access last item in list, even if list size has changed

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

list(range(x,y))

A

create a list of numbers

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

list[x:y]

A

take a slice from a list between index x and y

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

list[:x]

A

slice from beginning of list to x

17
Q

list[x:]

A

slice from x to end of the list

18
Q

list[-x:]

A

slice from end of list to x

19
Q

new_list = list[:]

A

make a copy of a list

20
Q

tuple

A

an immutable list. The name tuple comes from ‘quintuple’, ‘sextuple’, etc.