Question A (novice vs. competent): Consider the following code snippet:
list = [1, 2]<br />
list2 = list<br />
string = "abc"<br />
string2 = string<br />
list += [3, 4]<br />
string += "def"
What are the final values respectively of list2 and string2?
[1, 2]and"abc"[1, 2, 3, 4]and"abc"[1, 2]and"abcdef"[1, 2, 3, 4]and"abcdef"- I don’t know.
Question B (competent vs. expert): Consider the following Python interpreter session:
>>> x<br />
'0xFF'<br />
>>> y<br />
10<br />
>>> isinstance(x, str)<br />
True<br />
>>> isinstance(y, int)<br />
True
What would be the result of the expression x + y?
'0xFF10'265- A
TypeErrorexception will be raised, since you cannot add an integer to a string in Python. - The answer cannot be predicted given this code.
'0x109'