Lists Practice Quiz

To confirm that you understand the list concepts you’ve seen in Python, try to answer the following questions without opening Python.

Question 1

lists-quiz1: In the following code, what does this code print?:

stuff = [12, True, "test", 2.71, "ok", 8]
print(stuff[2])

Question 2

lists-quiz2: In the following code, what does this code print?:

stuff = [12, True, "test", 2.71, "ok", 8]
print(stuff[1:4])

Question 3

lists-quiz3: In the following code, what does this code print?:

stuff = [5, 1.3, ["cat", "dog", "fish"], "fox", [], 3.14, False]
print(stuff[2][0])

Question 4

lists-quiz4: In the following code, what does this code print?:

stuff = [5, 1.3, ["cat", "dog", "fish"], "fox", [], 3.14, False]
print(stuff[2][0][2])

Question 5

lists-quiz5: In the following code, what does this code print?:

stuff = [5, 1.3, ["cat", "dog", "fish"], "fox", [], 3.14, False]
print(len(stuff))

Question 6

lists-quiz6: In the following code, what does this code print?:

stuff = [5, 1.3, ["cat", "dog", "fish"], "fox", [], 3.14, False]
stuff.append("cow")
stuff.append("sheep")
stuff.append("horses")
print(len(stuff))

Question 7

lists-quiz7: In the following code, what does this code print?:

stuff = [5, 1.3, ["cat", "dog", "fish"], "fox", [], 3.14, False]
a = stuff.pop()
b = stuff.pop()
c = stuff.pop()
d = stuff.pop()
e = stuff.pop()
f = stuff.pop()
print(f)

Question 8

lists-quiz8: In the following code, what does this code print?:

def fancy_function(my_list):
    thing = 20
    for something in my_list:
        something = something - 2
        thing = thing - something
    return thing

print(fancy_function([5,4,4,3]))
Next Section - Project Overview