wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Lists and Elements

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the correct command to define a list?

a)

list = [ , , , ]

b)

list == [ , , , ]

c)

list = ( , , , )

d)

list = , , , ,

2.

list = [5, 3, 7, 3, 8, 9]

Which element is the list is represented by list[4]?

a)

7

b)

3

c)

8

d)

9

3.

list = [5, 3, 7, 3, 8, 9]

Which element is the list is represented by list[-1]?

a)

5

b)

3

c)

8

d)

9

4.

What is the output for this code?

num = [ 1, 2, 5 ]

val = [ 5, 6, 7 ]

total = num + val

print(total)

a)

[1, 2, 5, 5, 6, 7]

b)

[1, 2, 5, 6, 7]

c)

[5, 6, 7, 1, 2, 5]

d)

[1, 5, 2, 6, 5, 7]

5.

pic = ["movie", "jpeg", "selfie", "meme"]

What is generated by the command

print( pic[ :3] ) ?

a)

["movie", "jpeg"]

b)

["movie", "jpeg", "selfie"]

c)

["movie", "jpeg", "selfie", "meme"]

d)

["meme"]

6.

What is the output for this code?

red = [122, 123, 128, 129]

red[2] = 140

print(red)

a)

[140, 140]

b)

[122, 123, 129, 140]

c)

[122, 140, 128, 129]

d)

[122, 123, 140, 129]

7.

What is the output for this code?

food = ["bread", "cake", "donuts"]

print(food.append("biscuit"))

a)

['bread', 'cake', 'biscuit']

b)

['bread', 'cake', 'donuts', 'biscuit']

c)

['biscuit']

d)

['bread', 'biscuit', 'donuts']

8.

What is the correct output for this code?

list = [4, 5, 9, 5, 8, 12]

print(list.remove(5))

a)

[4, 9, 5, 8, 12]

b)

[4, 9, 8, 12]

c)

[4, 5, 9, 8, 12]

d)

[4, 5, 9, 5, 8, 12, 5]

9.

What is the output of this code?

front = [9, "ahead", True, 9, "top"]

print(front.count(9))

a)

0

b)

4

c)

3

d)

2

10.

What are the names of Koelmo's cats?

a)

Tom

b)

Bartholomew

c)

Mario

d)

Jerry