wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Chapter 7-8 Review

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What will run when the following code is executed?


Count = 0


while count < 10:

print count


count += 1

a)

0,1,2,3,4,5,6,7,8,9,10

b)

0,1,2,3,4,5,6,7,8,9

c)

1,2,3,4,5,6,7,8,9,

d)

0,1,2,3,4,5,6,7,8,9,10,11

2.

What will run when the following code is executed?


def my_function(x):


for i in range(0, len(x)):


x[i] = x[i]

return x


print my_function(range(5))

a)

0,1,2,3,4,5

b)

1,2,3,4,5

c)

0,1,2,3,4

d)

None of these choices

3.

What will run when the following code is executed?


N = [3, 5, 7]


def double_list(x):


for i in range(0, len(x)):


x[i] = x[i] *2

a)

3,10,7

b)

6,10,14

c)

3,5,7

d)

[6,10,14]

4.

What will run when the following code is executed?


N = [3, 5, 7]


def print_list(x):


for i in range(0, len(x)):


print x[i]


print_list(n)

a)

3,5,7

b)

[3,5,7]

c)

{3,5,7}

d)

None of the above

5.

What will run when the following code is executed?


def list_function(x):


x[2] = x[2] +12


return x


n = [26, 29, 32]


print x[2]

a)

32

b)

29

c)

44

d)

None of these choices

6.

What will run when the following code is executed?


N = [10, 20, 35]


n.append(42)


print n

a)

10,20,35,42

b)

{10,20,35,42}

c)

*10,20,35,42*

d)

[10,20,35,42]

7.

What will run when the following code is executed?


N = [22, 13, 5]


N[0] = n[0] * 3


print N[0]

a)

22

b)

66

c)

15

d)

None of the above

8.

What will run when the following code is executed?

n = [1,2,3,5,7,8]

print n[2]

a)

2

b)

3

c)

5

d)

7

9.

What will run when the following code is executed?


n = [10, 15, 25, 35, 45]


n.append(14)


print n

a)

10,15,25,35,45,14

b)

[10,15,25,35,45,14]

c)

{10,15,25,35,45}

d)

None of these options

10.

What will run when the following code is executed?

n = [0, 11, 13, 15, 22, 35]

n.pop(0)

print n

a)

[0, 11, 13, 15, 22, 35]

b)

[0,13, 15, 22, 35]

c)

[0, 11, 13, 15, 22,]

d)

[11, 13, 15, 22, 35]

11.

What will run when the following code is executed?


def list_function(x):


x[1] = x[1] + 3


return x

n = [3, 5, 7]


print list_function(n)

a)

3,5,7

b)

[3,8,7]

c)

3,8,7

d)

{3,8,7}

12.

What will run when the following code is executed?


n = [3, 5, 7]


def list_extender(lst):


lst.append(9)


return lst

print list_extender(n)

a)

[9,3,5,7]

b)

9,3,5,7

c)

3,5,7,9

d)

[3,5,7,9]

13.

What is a condition?

a)

A loop never exits

b)

An expression that decides whether the loop is going to continue being executed or not

c)

A statement that creates a function to determine the variance of a set of items

d)

None of the above

14.

What does the term “break” mean?

a)

A function that has not defined properly

b)

A loop that never exits

c)

A one-line statement that means exit the current loop

d)

None of the above

15.

What does the “+=” represent?

a)

The break statement

b)

The number of items in a list

c)

The increment of how much that specific count will run

d)

None of the above

16.

An “if” statement is an alternate way to stop a counting loop from running.

a)

True

b)

False

17.

What does the term “.randint”?

a)

Random Integer

b)

A method of spell-check

c)

An alternate way of "breaking" a counting loop

d)

None of the above

18.

In Python, the else block will continue to execute anytime the loop condition is evaluated to "False".

a)

True

b)

False

19.

"String manipulation" is useful for loops if you want to modify some content in a string.

a)

True

b)

False

20.

What does the term "enumerate" mean?

a)

Works by supplying a corresponding index to each element in the list

b)

Automatically sets the counting loops “start” number

c)

Automatically sets the counting loops “end” number

d)

None of the above