Multiple choice questions: Python

Oct 26, 2013 • Pauline Barmby

Novice from competent:

Which of the following Python commands is used to go back
to the top of an enclosing loop?

A) break
B) continue
C) pass
D) return

Expert from competent:

What is the output of the following Python code fragment?

a=[3,4,5]
b=[5,6,7,8]
a+b

A) [3,4,5,5,6,7,8]
B) [3,4,5,6,7,8]
C) [8,10,12]
D) [8,10,12,0]
E) TypeError: unsupported operand type(s) for +: list and list

 

On looking at this again the following morning, I’m not completely sure that the second question is quite competent-from-expert (maybe I’m not enough of an expert!). It certainly is higher-level compared to the first one, which is more of a “do you remember” type question.