Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 9 Test Review

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What does the following program print?

my_grid = [[2, 5, 7, 10], [-3, "hello", 9, "hi"], ["hello", "hi", "hello", "hi"], [True, False, True, False]] print(my_grid[0])

a)

[5, 7, 10, -3, ‘hello’, 9, ‘hi’]

b)

[2, 5]

c)

[[2, 5, 7, 10], [-3, ‘hello’, 9, ‘hi’]]

d)

[2, 5, 7, 10]

2.

What does the following program print?

my_grid = [[2, 5, 7, 10], [-3, "hello", 9, "hi"], ["hello", "hi", "hello", "hi"], [True, False, True, False]] print(my_grid[:2])

a)

[5, 7, 10, -3, ‘hello’, 9, ‘hi’]

b)

[2, 5]

c)

[[2, 5, 7, 10], [-3, ‘hello’, 9, ‘hi’]]

d)

[2, 5, 7, 10]

3.

What does this program print?

numbers = [x + x for x in range(4)] print(numbers)

a)

[0, 1, 2, 3, 4]

b)

[0, 1, 2, 3]

c)

[2, 4, 6, 8]

d)

[0, 2, 4, 6]

4.

What does this program print?

numbers = [x % 2 == 0 for x in range(0, 6)] print(numbers)

a)

[True, False, True, False, True, False]

b)

[0, 1, 0, 1, 0, 1, 0]

c)

[0, 1, 0, 1, 0, 1]

d)

[0, 1, 2, 3, 4, 5]

5.

Which of the following is a correct example of packing?

a)

my_list = [1, 2, 3]

x, y, z = my_list

b)

my_list = [1, 2, 3]

x = y = z = my_list

c)

x = 1

y = 2

z = 3

my_list = [x, y, z]

d)

x = 1

y = 2

z = 3

my_list = x = y = z

6.

Which of the following is a correct example of unpacking?

a)

my_list = [1, 2, 3]

x, y, z = my_list

b)

my_list = [1, 2, 3]

x = y = z = my_list

c)

x = 1

y = 2

z = 3

my_list = [x, y, z]

d)

x = 1

y = 2

z = 3

my_list = x = y = z

7.

Suppose you have the following dictionary, which stores the names and ages of people:

my_dictionary = {

"Bo": 32,

"Fiona": 28,

"Carlos": 45

}

Which line correctly prints Bo’s age?

a)

print(my_dictionary[0])

b)

print(my_dictionary[0][1])

c)

print(my_dictionary["Bo"])

d)

print(my_dictionary["Bo"][1])

8.

Refer to the following program. Are x and y equivalent?

x = [1, 2, 3]

y = x

a)

Yes

b)

No

9.

Refer to the following program. Are x and y identical?

x = [1, 2, 3]

y = x

a)

Yes

b)

No

10.

Refer to the following program. Are x and y equivalent?

x = [1, 2, 3]

y = [1, 2, 3]

a)

Yes

b)

No