NEW
Font size
WorksheetsYear 8 Lists
Total questions: 20
Worksheet time: 10mins
Which line of code creates a list of 3 numbers called evens?
evens = { 2, 4, 8 }
evens = [ 2 4 8 ]
evens = [ 2, 4, 8 ]
evens = [ "2", "4", "8" ]
Which line of code creates an empty list called echo?
echo = [ ]
empty = [ echo ]
empty = [ ]
echo = [ 0 ]
What is the index of the number 9 in this list? [ 6, 9, 3 ]
0
1
2
9
What is printed by this code:
x = [ "Hi", "there", "mate" ]
print( x[3] )
Hi
there
mate
An error message will be shown
What will be printed by this code?
z = [ "I", "don't", "know" ]
print( len(z) )
9
2
3
I don't know
What is printed by this code:
x = [ "Hi", "there", "mate" ]
print( x[1] )
Hi
there
mate
An error message will be shown
What is the name of the method to put an item on to the end of a list?
add
append
push
on_the_end
What is the name of the method to take an item out of a list given its value?
pop
remove
take
delete
What is the name of the method to take an item out of a list given its index?
pop
remove
take
delete
What is the name of the method to find the position of an item in a list?
position
find
index
count
What is the name of the method to find the number of times that an item is in a list?
total
find
index
count
What is the name of the method that puts the items of a list into order?
order
sort
arrange
count
Which line of code will change 'Ba' to 'Boo' in this list?
p = [ "Ya", "Ba", "Sucks" ]
p['Ba'] = 'Boo'
p[2] = 'Boo'
p[1] = 'Boo'
p = 'Boo'[1]
Which line of code will add 'Hooray' onto the end of the list w?
w = [ "Hip", "Hip" ]
w[2] = 'Hooray'
w.append('Hooray')
w = append('Hooray')
'Hooray' = append(w)
Which line of code will print how many times 3 is in the list g?
g = [ 1, 3, 8, 3, 6 ]
print(g.count(3))
print(count(g,3))
print(g.count[3])
print(3.count(g))
Which line of code will take all the 'fun' out of things?
things = [ 'joy', 'rapture', 'fun' ]
things.remove(2)
things.remove('fun')
things.pop('fun')
things.remove['fun']
Which line of code will take all the 'fun' out of things?
things = [ 'joy', 'rapture', 'fun' ]
things.pop(2)
things.pop('fun')
things.remove(2)
things.pop[2]
Which code will remove the smallest item from the list of nums?
nums = [2, 3, 1, 7, 6]
nums.remove(min)
nums.pop(0)
nums.sort()
nums.pop(0)
nums.pop(1)
Which code will change the number 2 in the list to 0?
nums = [ 4, 6, 3, 2, 9, 7 ]
z = nums.index(2)
nums[ z ] = 0
z = nums.index[ 2 ]
nums( z ) = 0
nums[2] = 0
nums.replace(2,0)
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 ]
k.remove(7)
k.pop(len(k) - 1)
k.pop(0)
k.remove(7)
k.sort()
k.pop( len(k) )
k.pop(0)
k.pop(7)
k.sort()
k.remove( len(k) )
k.remove(0)
k.remove(7)
k.sort()
k.pop( len(k) - 1 )
k.pop(0)
