wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Year 8 Lists

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which line of code creates a list of 3 numbers called evens?

a)

evens = { 2, 4, 8 }

b)

evens = [ 2 4 8 ]

c)

evens = [ 2, 4, 8 ]

d)

evens = [ "2", "4", "8" ]

2.

Which line of code creates an empty list called echo?

a)

echo = [ ]

b)

empty = [ echo ]

c)

empty = [ ]

d)

echo = [ 0 ]

3.

What is the index of the number 9 in this list? [ 6, 9, 3 ]

a)

0

b)

1

c)

2

d)

9

4.

What is printed by this code:

x = [ "Hi", "there", "mate" ]

print( x[3] )

a)

Hi

b)

there

c)

mate

d)

An error message will be shown

5.

What will be printed by this code?

z = [ "I", "don't", "know" ]

print( len(z) )

a)

9

b)

2

c)

3

d)

I don't know

6.

What is printed by this code:

x = [ "Hi", "there", "mate" ]

print( x[1] )

a)

Hi

b)

there

c)

mate

d)

An error message will be shown

7.

What is the name of the method to put an item on to the end of a list?

a)

add

b)

append

c)

push

d)

on_the_end

8.

What is the name of the method to take an item out of a list given its value?

a)

pop

b)

remove

c)

take

d)

delete

9.

What is the name of the method to take an item out of a list given its index?

a)

pop

b)

remove

c)

take

d)

delete

10.

What is the name of the method to find the position of an item in a list?

a)

position

b)

find

c)

index

d)

count

11.

What is the name of the method to find the number of times that an item is in a list?

a)

total

b)

find

c)

index

d)

count

12.

What is the name of the method that puts the items of a list into order?

a)

order

b)

sort

c)

arrange

d)

count

13.

Which line of code will change 'Ba' to 'Boo' in this list?

p = [ "Ya", "Ba", "Sucks" ]

a)

p['Ba'] = 'Boo'

b)

p[2] = 'Boo'

c)

p[1] = 'Boo'

d)

p = 'Boo'[1]

14.

Which line of code will add 'Hooray' onto the end of the list w?

w = [ "Hip", "Hip" ]

a)

w[2] = 'Hooray'

b)

w.append('Hooray')

c)

w = append('Hooray')

d)

'Hooray' = append(w)

15.

Which line of code will print how many times 3 is in the list g?

g = [ 1, 3, 8, 3, 6 ]

a)

print(g.count(3))

b)

print(count(g,3))

c)

print(g.count[3])

d)

print(3.count(g))

16.

Which line of code will take all the 'fun' out of things?

things = [ 'joy', 'rapture', 'fun' ]

a)

things.remove(2)

b)

things.remove('fun')

c)

things.pop('fun')

d)

things.remove['fun']

17.

Which line of code will take all the 'fun' out of things?

things = [ 'joy', 'rapture', 'fun' ]

a)

things.pop(2)

b)

things.pop('fun')

c)

things.remove(2)

d)

things.pop[2]

18.

Which code will remove the smallest item from the list of nums?

nums = [2, 3, 1, 7, 6]

a)

nums.remove(min)

b)

nums.pop(0)

c)

nums.sort()

nums.pop(0)

d)

nums.pop(1)

19.

Which code will change the number 2 in the list to 0?

nums = [ 4, 6, 3, 2, 9, 7 ]

a)

z = nums.index(2)

nums[ z ] = 0

b)

z = nums.index[ 2 ]

nums( z ) = 0

c)

nums[2] = 0

d)

nums.replace(2,0)

20.

TRICKY! Put this list into order, then remove the smallest and largest items, as well any number 7s.

k = [ 7, 6, 4, 9, 7, 1, 8 ]

a)

k.remove(7)

k.pop(len(k) - 1)

k.pop(0)

b)

k.remove(7)

k.sort()

k.pop( len(k) )

k.pop(0)

c)

k.pop(7)

k.sort()

k.remove( len(k) )

k.remove(0)

d)

k.remove(7)

k.sort()

k.pop( len(k) - 1 )

k.pop(0)