3 ms·
The only thing that was truly python specific was the UTF8 question - you'd need to know the library. The stuff about reference equality is pretty common in alm
by johnfn 9y ago
The only thing that was truly python specific was the UTF8 question - you'd need to know the library. The stuff about reference equality is pretty common in almost every language that abstracts away pointers - js, ruby, c#... The thing about closures was a basic closure question that anyone with experience in a language about closures could answer.
- eveningcoffee 9y agoI would argue that UTF8 was a character encoding knowledge question. Two of the answers were clearly wrong and the array did contains values over 127, so there was only a single possible logical answer.
- fenomas 9y agoI only looked at three questions, but two of them were entirely Python specific. Question 2 asks you to choose between: queue.extend(node) queue.extend([node]) queue.extend(node.children) Sure, I could take a guess which one of those appends the contents of "node" to the end of "queue", but I'd be guessing about syntax, not programming. After that, and question 3 about what happens when you assign to a function argument, I realized it was a Python quiz and stopped reading.
- ammon 9y agoThe intent was that node.children would be the giveaway. The question is about BFS, and you'll notice that only one of the answers references the node's children (in a sensible way). The intent was that that would be enough to answer it without knowing python queue syntax (for what it's worth, I know python well and don't have the deque API in my head)
- fenomas 9y agoThanks for the explanation, please see sibling comment for context. I think that a comment like # assume "node" is an object with "value" and "children" properties would make this question clearer.
- Yen 9y agoThat's not python specific. When you're running BFS, after visiting a node, you next visit each of that node's children. From a python-specific viewpoint, dequeue.extend appends a given list to the end of the queue. The first example will raise an exception, but the other two are perfectly valid, and their behavior isn't special to python - it's just asking whether you'll want to vi it this same node again, or the node's children. Incidentally, it's not as if there's any standard library 'node' class with a children method. This was a structure they defined, but did not share the definition of.
- fenomas 9y ago> Incidentally, it's not as if there's any standard library 'node' class with a children method. This was a structure they defined, but did not share the definition of. Ahh, that makes things much clearer. Since they weren't otherwise mentioned, I supposed that "value" and "children" were properties of some existing Python collection object - and that the question was asking how "queue.extend" expected that collection to be passed in. I guess this is the inverse of a language-specific question - if one knows that "children" has no significance in Python then I suppose the question would be clearer.