wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CSC108 - Lecture 5

Total questions: 10

Worksheet time: 25mins

Name
Class
Date
1.

a,b,c = 5,6,7

a += b

c -= b

What integer values do a, b, and c hold?

a)

a = 13, b = 6, c = 0

b)

a = 11, b = 6, c = 1

c)

a = 11, b = 0, c = 1

d)

Runtime Error!

2.

a = [1, 2, 3]

b = a*3

What would the output of the command print(b) be?

a)

[1, 2, 3], [1, 2, 3], [1, 2, 3]

b)

[[1, 2, 3], [1, 2, 3], [1, 2, 3]]

c)

[1, 2, 3, 1, 2, 3, 1, 2, 3]

d)

Runtime Error!

3.

Given the following segment of code, what integer value does counter hold?

a)

counter = -1

b)

counter = -8

c)

counter = -7

d)

counter = 1

4.

a = [2, 4, 6]

x, y, z = a

What are the values of x, y, and z?

a)

x = 1, y = 2, z = 3

b)

x = 2, y = 4, z = 6

c)

This does not work!

5.

Given the following segment of code, what is the output?

a)

[0]

b)

[1]

c)

[0, 1]

d)

"q"

6.

Given the following segment of code, what is the output?

a)

True

b)

False

c)

None

d)

None of the Answers Provided

7.

CHALLENGE QUESTION: Given the following segment of code, what is the correct output?

a)

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

b)

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

c)

[0, None, 1, None, 2, None]

d)

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

8.

Given the following segment of code, what is the correct output?

a)

18

b)

15

c)

48

d)

35

9.

Given the following segment of code, the following are TRUE:

a)

x == y == z

b)

y = 81

c)

c = 18

d)

c = 20

e)

(y == z) != x

10.

Given the following segment of code, the following are TRUE:

a)

The variables: a, b, c, and n, all remain unmodified

b)

w = 63

c)

w = 65

d)

v = 9

e)

v = 90