[ARCHIVED] Need help with fill-in-the-blanks on quizzes - my answers need square brackets

aj-v
Community Member

Hello everyone,

I'm teaching a Python programming class and we're doing a unit on lists, which in Python use the square brackets.  Certain operations change the contents of the list, and I'd like to quiz students on this by having a small program that does several list manipulations and prints the list after each change. 

The question would look like this:

-----------------------------------------

Write what will be printed by each of the print statements in the following code.

ex = [5, 3, 0, 1, 2] 
print(ex) # Answer A
print(ex[0:2]) # Answer B
print(ex[-1]) # Answer C
ex.append(8) 
print(ex) # Answer D
ex.remove(0) 
print(ex) # Answer E
ex.pop() 
print(ex) # Answer F

Enter your answers here:

  • Answer A [A]
  • Answer B [B]
  • Answer C [C]
  • Answer D [D]
  • Answer E [E]
  • Answer F [F]

--------------------------------------------

The trouble is, the answer for A is [5, 3, 0, 1, 2] (the list before anything is done) and most of the other answers are also lists. I can't seem to get Canvas to accept answers in square brackets as non-empty, so I cannot save this question to the quiz.    

Labels (2)
0 Likes