wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 8

Total questions: 7

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following programs would produce the following output:

a)

my_list = ["honey", "bread", "jelly", "plates"]

for index in range(len(my_list)): print(str(index) + ". " + my_list)

b)

my_list = ["honey", "bread", "jelly", "plates"]

for index in range(len(my_list)): print(str(index+1) + ". " + my_list[index])

c)

my_list = ["honey", "bread", "jelly", "plates"]

for index in my_list: print(str(index+1) + ". " + my_list[index])

d)

my_list = ["honey", "bread", "jelly", "plates"]

for index in len(my_list): print(str(index) + ". " + my_list[index])

2.

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

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

a)

Tuple

b)

List

c)

2D List

d)

String

3.

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)

ages = ages + (1, 3, 5)

print(ages[2])

c)

ages = ages[2:]

d)

ages[0] = 3

4.

What does this code snippet print?

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

print("a".join(fruit))

a)

bnn

b)

bnn

ba na na

c)

banan

d)

bbb

5.

What is the value of num after this code runs?

shapes = ["triangle", "square", "hexagon", "circle", "pentagon"]

num = len(shapes)

a)

0

b)

4

c)

5

d)

33

6.

What does this program print?

a)

My favorite animal is a dog or penguin

b)

My favorite animal is a penguin or chipmunk

7.

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]