wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Lists

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

2.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

3.

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

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

a)

"John"

b)

"Harry"

c)

"Jesse"

4.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

5.

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"]

a)

nameList.append(Felipe)

b)

append(nameList,"Felipe")

c)

nameList.append["Felipe",7]

d)

nameList.append("Felipe")

6.

Which of these is a list?

a)

fruit = ["pineapples", "mangoes", "bananas"]

b)

fruit = "pineapples", "mangoes", "bananas"

c)

fruit = {"pineapples", "mangoes", "bananas"}

d)

fruit = ("pineapples", "mangoes", "bananas")

7.

If you want to create an empty list called islands, which of the following pieces of code is correct?

a)

islands = { }

b)

islands = ( )

c)

islands = [ ]

d)

islands = < >

8.

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

a)

1

b)

0

c)

a

d)

A

9.

What is the index of the name 'Paula' in the following list:

names = ["Paul","Phillip","Paula","Phillipa"]

a)

0

b)

1

c)

2

d)

3

10.
What is the output when we execute list(“hello”)?
a)
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
b)
 [‘hello’] 
c)
[‘llo’]
d)
 [‘olleh’]
11.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

del mariana_islands[0]

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Tinian', 'Rota']

c)

['Saipan', 'Tinian']

d)

['Saipan', 'Rota']

12.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.pop()

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Tinian', 'Rota']

c)

['Saipan', 'Tinian']

d)

['Saipan', 'Rota']

13.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.remove('Tinian')

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Tinian', 'Rota']

c)

['Saipan', 'Tinian']

d)

['Saipan', 'Rota']

14.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota', 'Guam']

mariana_islands.sort()

print(mariana_islands)

a)

['Tinian', 'Saipan', 'Rota', 'Guam']

b)

['Guam', 'Tinian', 'Rota', 'Saipan']

c)

['Saipan', 'Rota', 'Guam', 'Tinian']

d)

['Guam', 'Rota', 'Saipan', 'Tinian']

15.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.insert(0, 'Guam')

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Guam', 'Tinian', 'Rota']

c)

['Saipan', 'Tinian', 'Rota', 'Guam']

d)

['Guam', 'Saipan', 'Tinian', 'Rota']

16.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.append('Guam')

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Guam', 'Tinian', 'Rota']

c)

['Saipan', 'Tinian', 'Rota', 'Guam']

d)

['Guam', 'Saipan', 'Tinian', 'Rota']

17.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands[0] = 'Guam'

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Guam', 'Tinian', 'Rota']

c)

['Saipan', 'Tinian', 'Rota', 'Guam']

d)

['Guam', 'Saipan', 'Tinian', 'Rota']

18.

What is the output of program below?


mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']

print(mariana_islands[-1])

a)

Guam

b)

Saipan

c)

Tinian

d)

Rota

19.

What is the output of program below?


mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']

print(mariana_islands[1])

a)

Guam

b)

Saipan

c)

Tinian

d)

Rota

20.

What is the output of the program below?


mariana_islands = ['Guam', 'Saipan', 'Tinian', 'Rota']

cmni = mariana_islands[1:]

len(cmni)

a)

1

b)

2

c)

3

d)

4