NEW
Font size
WorksheetsPython Lists
Total questions: 20
Worksheet time: 11mins
Which of these is the best description of a list in Python?
A list is a collection of data that has an order and can be changed
A list is a lot of variables
A list is used for shopping
A list is a collection of data that cannot hold duplicated data and cannot be changed
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
List items have an index number. In the following list, which item has the index number of 3?
["John", "Harry", "Jesse", "John", "Harry", "Harry"]
"John"
"Harry"
"Jesse"
Which of these pieces of code would return the name "Harry" from the following list?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList()
nameList[1]
NameList(4)
nameList["4"]
The list needs one more name added to the end - "Felipe". Which piece of code below would do this?
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList.append(Felipe)
append(nameList,"Felipe")
nameList.append["Felipe",7]
nameList.append("Felipe")
Which of these is a list?
fruit = ["pineapples", "mangoes", "bananas"]
fruit = "pineapples", "mangoes", "bananas"
fruit = {"pineapples", "mangoes", "bananas"}
fruit = ("pineapples", "mangoes", "bananas")
If you want to create an empty list called islands, which of the following pieces of code is correct?
islands = { }
islands = ( )
islands = [ ]
islands = < >
Each item in a list has an "address" or index. The first index in a Python list is what?
1
0
a
A
What is the index of the name 'Paula' in the following list:
names = ["Paul","Phillip","Paula","Phillipa"]
0
1
2
3
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
del mariana_islands[0]
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Tinian', 'Rota']
['Saipan', 'Tinian']
['Saipan', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.pop()
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Tinian', 'Rota']
['Saipan', 'Tinian']
['Saipan', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.remove('Tinian')
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Tinian', 'Rota']
['Saipan', 'Tinian']
['Saipan', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota', 'Guam']
mariana_islands.sort()
print(mariana_islands)
['Tinian', 'Saipan', 'Rota', 'Guam']
['Guam', 'Tinian', 'Rota', 'Saipan']
['Saipan', 'Rota', 'Guam', 'Tinian']
['Guam', 'Rota', 'Saipan', 'Tinian']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.insert(0, 'Guam')
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Guam', 'Tinian', 'Rota']
['Saipan', 'Tinian', 'Rota', 'Guam']
['Guam', 'Saipan', 'Tinian', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands.append('Guam')
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Guam', 'Tinian', 'Rota']
['Saipan', 'Tinian', 'Rota', 'Guam']
['Guam', 'Saipan', 'Tinian', 'Rota']
What is the output of program below?
mariana_islands = ['Saipan', 'Tinian', 'Rota']
mariana_islands[0] = 'Guam'
print(mariana_islands)
['Saipan', 'Tinian', 'Rota']
['Guam', 'Tinian', 'Rota']
['Saipan', 'Tinian', 'Rota', 'Guam']
['Guam', 'Saipan', 'Tinian', 'Rota']
What is the output of program below?
mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']
print(mariana_islands[-1])
Guam
Saipan
Tinian
Rota
What is the output of program below?
mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']
print(mariana_islands[1])
Guam
Saipan
Tinian
Rota
What is the output of the program below?
mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']
cmni = mariana_islands[1:]
len(cmni)
1
2
3
4
