Python Lists Flashcards

1
Q

Fill in the blank: lists are one of _ built-in data types in Python

A

4

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

What are those 4 data types?

A

Lists, sets, tuples, dictionaries

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

What are the 3 attributes of Python lists?

A

Ordered, changeable, allow duplicate values

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

How do you access list item values?

A

Reference the index number:

thislist[1] accesses the value of the 2nd item in the list

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

What method adds items to the end of a list?

A

append()

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

What method adds items at a specified index?

A

insert()

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

What method adds items from any iterable to the current list?

A

extend()

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

What list method takes away the specified item?

A

remove()

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

What list method removes the specified index?

A

pop()

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

What is the structure for a list comprehension?

A

[expression for item in iterable if condition == True]

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