wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Arrays

Total questions: 11

Worksheet time: 6mins

Name
Class
Date
1.

Which of these is the correct way to declare a list (array) in Python?

Hint: look carefully at the type of brackets used.

a)

fruit = ["apples", "oranges", "bananas"]

b)

fruit = "apples", "oranges", "bananas"

c)

fruit = {"apples", "oranges", "bananas"}

d)

fruit = ("apples", "oranges", "bananas")

2.

Each item in a list has an "address" or index. What is the first index in a Python list?

a)

1

b)

0

c)

a

d)

A

3.

What is the position of the name 'Paula' in the following list:
names = ["Paul","Phillip","Paula","Phillipa"]

a)

0

b)

1

c)

2

d)

3

4.
In a list called "players", if you wanted to add a player called "Bob" to the list, which of the following examples of code would be correct?
a)
players.add("Bob")
b)
player.append("Bob")
c)
players.append("Bob")
d)
players.addend("Bob")
5.

In programming, lists are often known as...

a)

Arrays

b)

Elements

c)

Indexes

d)

Data

6.

List items have an index number. In the following list, which item has the index number 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

7.

Which code would I use to add an item to a list?

a)

variable.add()

b)

variable.append()

c)

append.variable()

d)

add.variable()

8.

An empty list can be declared as:

a)

fruitList = ""

b)

fruitList = ["empty"]

c)

fruitList == []

d)

fruitList = []

9.

Which of the following commands will return the length of the list mylist?

a)

length(mylist)

b)

len(mylist)

c)

mylist.length()

d)

mylist.len()

10.

a)

a

b)

b

c)

c

d)

Error

11.

a)

1

b)

2

c)

3

d)

4