wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CodeHS Python Unit 8 Review

Total questions: 15

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

Which of the following data structures is immutable?

a)

Tuple

b)

List

c)

Dictionary

d)

2D List

2.

What does this program print?

a)

[48, 56, 64, 65, [60, 61, 62]]

b)

[48, 56, 60, 61, 62, 64, 65]

c)

[48, 56, 64, 65, 60, 61, 62]

d)

The program will error.

3.

How many times does this program print "That's a large class!?"

a)

0

b)

1

c)

4

d)

6

4.

What would the following program print to the screen when run?

a)

7

0

0

d

n

o

B

b)

0

0

7

B

o

n

d

c)

B

o

n

d

0

0

7

d)

700donB

5.

Given the following list:

my_list = ["s", "Z", "e", "c", "c", "e", "r", "h", "e", "p", "t"]

which program below would give the following output:

s

e

c

r

e

t

a)

b)

c)

d)

6.

Which values entered into ‘my_list’ would print a value of ‘-1’ after the program has run?

a)

5, -10, 6

b)

-10, -5, 6

c)

-5, 10, 6

d)

-5, 0, 10, 6

7.

Which of the following programs would produce the following output:

1. honey

2. bread

3. jelly

4. plates

a)

b)

c)

d)

8.

Which of the following programs would alter my_list to consist of the following:

[‘red’, ‘green’, ‘blue’, ‘orange’, ‘yellow’]

a)

b)

c)

d)

9.

What will be the output of the following program?

a)

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

b)

[1, 2, 3, 4, 5]

c)

[1, 2, 3, 4, 6, 7, 8, 9]

d)

[1, 2, 3, 4, 5, 6, 7, 8]

10.

What kind of data structure is user_data in the following declaration?

user_data = ("TJ", 24, "artLover123")

a)

Tuple

b)

List

c)

String

d)

2d List

11.

What kind of data structure is user_data in the following declaration?

user_data = ["TJ", 24, "artLover123"]

a)

Tuple

b)

List

c)

String

d)

2d List

12.

Which of the following lines of code WILL cause an error? Use the following definition of ages:

ages = (12, 5, 8)

a)

ages = ages + (1, 3, 5)

b)

print(ages[2])

c)

ages = ages[2:]

d)

ages[0] = 3

13.

What does this code snippet print?

fruit = ["b", "n", "n"]

print("a".join(fruit))

a)

bnn

b)

ba na na

c)

banan

d)

banana

14.

What is the value of num after this code runs?

a)

0

b)

4

c)

5

d)

35

15.

What does this program print?

a)

My favorite animal is a dog or penguin

b)

My favorite animal is a penguin or chipmunk

c)

My favorite animal is a dog penguin chipmunk

d)

My favorite animal is a dog or chipmunk