NEW
Font size
WorksheetsPython Arrays
Total questions: 11
Worksheet time: 6mins
Which of these is the correct way to declare a list (array) in Python?
Hint: look carefully at the type of brackets used.
fruit = ["apples", "oranges", "bananas"]
fruit = "apples", "oranges", "bananas"
fruit = {"apples", "oranges", "bananas"}
fruit = ("apples", "oranges", "bananas")
Each item in a list has an "address" or index. What is the first index in a Python list?
1
0
a
A
What is the position of the name 'Paula' in the following list:
names = ["Paul","Phillip","Paula","Phillipa"]
0
1
2
3
In programming, lists are often known as...
Arrays
Elements
Indexes
Data
List items have an index number. In the following list, which item has the index number 3?
["John", "Harry", "Jesse", "John", "Harry", "Harry"]
"John"
"Harry"
"Jesse"
Which code would I use to add an item to a list?
variable.add()
variable.append()
append.variable()
add.variable()
An empty list can be declared as:
fruitList = ""
fruitList = ["empty"]
fruitList == []
fruitList = []
Which of the following commands will return the length of the list mylist?
length(mylist)
len(mylist)
mylist.length()
mylist.len()
a
b
c
Error
1
2
3
4
