Complex Data Types Flashcards

1
Q

Create a LIST with 3 elements.
Then Print the length of the list.
Is a List Mutable?

A

l = [1, 2, 3]
print(len(l)) #3
Yes

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

Given the list: l=[1,2,3,4]
What is the result of…

1) Append the number 4 at the end.
2) Insert a 7 into position 2
3) Concatenate the list with 8
4.) Print the result

A

l = [1,2,7,3,4,4,8]

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

Remove the first element from list l=[1, 2, 3, 4]

A

l.remove[1]

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

Reverse the list [1, 2, 3, 4]

A

[4, 3, 2, 1]

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

Sort the list and print the result
l = [3, 2, 5, 1]

A

l.sort()

[1, 2, 3, 5]

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