wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

9.3 L3 Python Lists

Total questions: 10

Worksheet time: 5mins

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.

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

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

a)

nameList.append(Felipe)

b)

append(nameList,"Felipe")

c)

nameList.append["Felipe",7]

d)

nameList.append("Felipe")

5.

What would this code do?

a)

Remove the name "Felipe" from the list

b)

Remove the first copy of "John" from the list

c)

Remove the name "Felipe" from the list and print it out to the shell

d)

An error

6.

What would this code show on the screen?

a)

7

b)

6

c)

5

d)

4

e)

An error

7.

What would this code return on the shell?

a)

Nothing

b)

An error

c)

"Woo hoo, you scored!"

d)

"Raheem"

8.

What would this code show in the shell?

a)

3

b)

2

c)

1

d)

0

e)

An error

9.

What would this code show in the shell?

a)

3

b)

2

c)

1

d)

0

e)

An error

10.

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"