wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python List

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Lists are used to store single item in a single variable.

a)

True

b)

False

2.

List items are ordered, changeable, and allow duplicate values.

a)

True

b)

False

3.

List items are indexed, the first item has index [1], the second item has index [2] etc.

a)

True

b)

False

4.

When we say that lists are ordered, it means that the items have a defined order, and that order will not change.

a)

True

b)

False

5.

List items can be of any data type:

a)

True

b)

False

6.

If you add new items to a list, the new items will be placed at the end of the list.

a)

True

b)

False

7.

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]

8.

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"

9.

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

10.

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

11.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
12.

Is this the correct code for a list?

register = {"Sam", "Pheobe", Georgia", Richard"}

a)

Yes

b)

No

13.

The count() method returns the number of times the specified element appears in the list.

What is the output of this code?

a)

3

b)

2

c)

1

d)

0

14.

Output of this code?

a)

[2,4,6,8,10]

b)

['2','4','6','8','10']

c)

[0,2,4,6,8]

d)

[10,8,6,4,2]

15.

What is the index of “grape” in the list

[“apple”, “grape”, “orange”, “watermelon”]?

a)

0

b)

1

c)

2

d)

3