NEW
Font size
WorksheetsPython List
Total questions: 15
Worksheet time: 8mins
Lists are used to store single item in a single variable.
True
False
List items are ordered, changeable, and allow duplicate values.
True
False
List items are indexed, the first item has index [1], the second item has index [2] etc.
True
False
When we say that lists are ordered, it means that the items have a defined order, and that order will not change.
True
False
List items can be of any data type:
True
False
If you add new items to a list, the new items will be placed at the end of the list.
True
False
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")
Is this the correct code for a list?
register = {"Sam", "Pheobe", Georgia", Richard"}
Yes
No
The count() method returns the number of times the specified element appears in the list.
What is the output of this code?
3
2
1
0
Output of this code?
[2,4,6,8,10]
['2','4','6','8','10']
[0,2,4,6,8]
[10,8,6,4,2]
What is the index of “grape” in the list
[“apple”, “grape”, “orange”, “watermelon”]?
0
1
2
3
