wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Practice Quiz( List)

Total questions: 22

Worksheet time: 10mins

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.

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

6.

Which of these codes is correct for creating a list of numbers?

a)

num = ('10','29','37','109')

b)

num = ['10','29','37','109']

c)

num == ('10','29','37','109')

d)

num = ['10 29 37 109']

7.

What is the index number for 'Spain'?

['England','Brazil','Spain','France']

a)

0

b)

1

c)

2

d)

3

8.

How do i remove something from a list?

a)

variable.append()

b)

variable.delete()

c)

variable.remove()

d)

variable=(new variable)

9.

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

a)

variable.add()

b)

variable.append()

c)

append.variable()

d)

add.variable()

10.

What is used to separate elements in a list?

a)

Bracket

b)

Comma

c)

Full Stop

d)

Space

11.

variable.sort() will do what?

a)

Sort the list into alphabetical order

b)

Sort the list into reverse order

c)

Create a new list

d)

Error

12.

____________function can be used to insert an element/object at a specified index.

a)

extend( )

b)

insert ( )

c)

append( )

13.

What is the function of the reverse method for lists?

a)

removes the first occurrence of the information inside the parenthesis

b)

adds the information inside the parenthesis to the end of the list

c)

reverses the order of the elements inside a list

d)

sorts the list (lowest to highest for numbers and alphabetical order for strings)

14.

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

nameList[6] ="Susie"

print(nameList)

What would be the output

a)

['John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry', 'Susie']

b)

['Susie', 'John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry']

c)

['Susie']

d)

Error

15.

Which function(s) out of the following will increase the length of the list?

a)

insert()

b)

index()

c)

append()

d)

extend()

e)

reverse()

16.

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

17.

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

The list will be slice and show Harry and Jesse only. Which piece of code below would do this?

a)

print(nameList[1:3])

b)

print(nameList[0:1])

c)

print(nameList[1:2])

d)

print(nameList["Harry":"Jesse"])

18.

To insert an the string "Pedro" in the first position of a the nameList we use

a)

nameList.append("Pedro, 1")

b)

nameList.insert("Pedro",0)

c)

nameList.insert(1, "Pedro")

d)

nameList.insert(0, "Pedro")

19.

variable.sort() will do what?

a)

Sort the list into alphabetical order

b)

Sort the list into reverse order

c)

Create a new list

d)

Error

20.

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

del nameList[3]

print(nameList)

What would be the output

a)

['John', 'Harry', 'Jesse', 'Marry', 'Larry']

b)

['John', 'Harry', 'Jesse', 'John', 'Larry']

c)

['John', 'Harry', 'John', 'Marry', 'Larry']

d)

Error

21.

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

print(nameList.count("John"))

What would be the output

a)

1

b)

2

c)

3

d)

Error

22.

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

nameList[6] ="Susie"

print(nameList)

What would be the output

a)

['John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry', 'Susie']

b)

['Susie', 'John', 'Harry', 'Jesse', 'John', 'Marry', 'Larry']

c)

['Susie']

d)

Error