NEW
Font size
WorksheetsLong Test Part 3 - LIsts_IT1107
Total questions: 20
Worksheet time: 10mins
Which of the following correctly creates a list in Python?
list = (1, 2, 3)
list = {1, 2, 3}
list = [1, 2, 3]
list = <1, 2, 3>
What is the index of the first element in a Python list?
-1
0
1
Depends on the list
Which operation adds an item to the end of a list?
list.add(x)
list.push(x)
list.append(x)
list.insert(x)
What does the len() function return when used on a list?
Total memory used
Last element
Number of elements
Size of list in bytes
Which of the following removes and returns the last element of a list?
remove()
pop()
delete()
discard()
What happens if you try to access an index that does not exist?
Returns None
Returns an empty string
Returns False
Raises an IndexError
Which list method inserts an item at a given position?
insert()
append()
extend()
place()
Which statement about Python lists is TRUE?
Lists are immutable
Lists cannot be nested
Lists require all elements to be integers
Lists can hold elements of different data types
What does list.extend([x, y]) do?
Adds [x, y] as a single element
Replaces existing elements
Adds x and y individually to the list
Removes x and y
Which of the following demonstrates the correct way to add something to the following list variable?
temperatures = [44, 36, 72]
append(temperatures, 42)
temperatures = temperatures + 42
temperatures.append(42)
temperatures.append[1]
What is the output of the following?
1
-1
4
3
What will this code print?
[10, 20]
[20, 30]
[20, 30, 40]
[30, 40]
What does this code print?
[1, 2]
[3, 4]
[1, 2, 3, 4]
10
What will this code print?
[5, 2, 9, 1]
[9, 5, 2, 1]
Error
[1, 2, 5, 9]
What is the result of this code?
[1, 2, 3]
[1, 10, 3]
[10, 2, 3]
Error: lists are immutable
What is the output of the following code?
9
12
6
3
What does this code print?
["pen", "paper"]
["pen", "paper", "book"]
["pen", "paper", "book", "bag"]
["bag"]
What does this code print?
[1, 2, 10, 3]
[10, 1, 2, 3]
[1, 10, 2, 3]
[1, 2, 3, 10]
What will this code output?
4
5
3
2
What is the output?
x-y-z-
x, y, z-
-x y z-
x y z -
