Font size
WorksheetsPractice Quiz( List)
Total questions: 22
Worksheet time: 10mins
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"]
Each item in a list has an "address" or index. The first index in a Python list is what?
1
0
a
A
Which of these codes is correct for creating a list of numbers?
num = ('10','29','37','109')
num = ['10','29','37','109']
num == ('10','29','37','109')
num = ['10 29 37 109']
What is the index number for 'Spain'?
['England','Brazil','Spain','France']
0
1
2
3
How do i remove something from a list?
variable.append()
variable.delete()
variable.remove()
variable=(new variable)
Which code would i use to add an item to a list?
variable.add()
variable.append()
append.variable()
add.variable()
What is used to separate elements in a list?
Bracket
Comma
Full Stop
Space
variable.sort() will do what?
Sort the list into alphabetical order
Sort the list into reverse order
Create a new list
Error
____________function can be used to insert an element/object at a specified index.
extend( )
insert ( )
append( )
What is the function of the reverse method for lists?
removes the first occurrence of the information inside the parenthesis
adds the information inside the parenthesis to the end of the list
reverses the order of the elements inside a list
sorts the list (lowest to highest for numbers and alphabetical order for strings)
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
nameList[6] ="Susie"
print(nameList)
What would be the output
['John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry', 'Susie']
['Susie', 'John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry']
['Susie']
Error
Which function(s) out of the following will increase the length of the list?
insert()
index()
append()
extend()
reverse()
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")
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
The list will be slice and show Harry and Jesse only. Which piece of code below would do this?
print(nameList[1:3])
print(nameList[0:1])
print(nameList[1:2])
print(nameList["Harry":"Jesse"])
To insert an the string "Pedro" in the first position of a the nameList we use
nameList.append("Pedro, 1")
nameList.insert("Pedro",0)
nameList.insert(1, "Pedro")
nameList.insert(0, "Pedro")
variable.sort() will do what?
Sort the list into alphabetical order
Sort the list into reverse order
Create a new list
Error
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
del nameList[3]
print(nameList)
What would be the output
['John', 'Harry', 'Jesse', 'Marry', 'Larry']
['John', 'Harry', 'Jesse', 'John', 'Larry']
['John', 'Harry', 'John', 'Marry', 'Larry']
Error
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
print(nameList.count("John"))
What would be the output
1
2
3
Error
nameList = ["John", "Harry", "Jesse", "John", "Marry", "Larry"]
nameList[6] ="Susie"
print(nameList)
What would be the output
['John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry', 'Susie']
['Susie', 'John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry']
['Susie']
Error
