I think what you’re really saying is that I made an error in saying that it’s for version 3.12-3.14, when 3.14 hasn’t been released yet. I should have said 3.13, since that actually exists. And actually, I tested most things out in 3.11 as well to be safe, so I’m going to update it to say 3.11-3.13.
I felt obligated to take it because I was one of the people to like your previous post, but I did miserably. I choose to interpret this saying I only write nice idiomatic code, and so I’ve never needed to learn these dark esoteric details.
One note: somehow “Which of these is a valid integer literal?” is the only question that is listed as optional, I assume that was an accident.
By the way, I don’t see people’s specific right and wrong answers, but I do have stats on which answers have been selected. By and large, people seem to be doing well; in most questions, the majority response is also the correct one. There are only two that are notably otherwise are the questions on integer and string literals.
Overall I am okay with the ones I didn’t get, because I genuinely did not know most of those, the one I did and still made a mistake was the f-string one, for which I didn’t want to spend the attention it needed. There are two cases I am slightly annoyed with:
First one, I got confused with 0 and O with Google’s font. Also I was extremely tempted. This, I am annoyed with myself.
The second one is more interesting. “Which of these is NOT a statement?” question tripped me up. One was blatantly wrong, but I didn’t choose that one, because if it were legal, it could be counted as a statement. I chose the one that is an expression. Although if the logic was “all expressions are statements”, then I got owned. Otherwise I think the wording could be improved.
Yeah, I can’t blame you; sadly, I don’t have much choice there. I wanted to use some monospaced (code) text in places, and had to make do with bold. I actually went through three or four different quiz sites before going with the Google form, because they either wanted money for anything more than ten responses a month, or just had too many ads, or something.
There is a very very strange subtlety here.
The yield keyword can be used in both statement and expression form.
In the context of a larger expression, yield x is a valid expression, so (yield x) is indeed a statement-expression. However, due to a quirk of grammar, a stand-alone yield has to be its own type of statement. But, that’s a very VERY obscure subtlety, and the logic “any expression is a valid statement” is also a valid justification. One of the other three options is, in fact, not legal Python code (and thus definitely not a statement).
Regarding the subtlety, it is certainly very strange. I probably didn’t read that part of the docs very carefully! After reading your reply, I tried looking at AST dump of return 0 , return (yield 0), and yield 0. I got slightly more confused by the documentation of ast.Yield, which unequivocally calls it an expression.
The arguments/parameters one I got wrong, not because I didn’t know the correct answer, but because I got muddled over which is an argument and which is a parameter!!! Must be time for me to go to bed…
Damn it. Those are exactly the two questions I got wrong. Nice quiz! Too bad the form doesn’t allow selection of multiple choices for questions that have multiple correct answers.
I mean, technically yes… but by that token, you could shadow type and completely redefine the question about dunder methods, or any of the other things mentioned. Give yourself one bonus point for being technically correct, but score yourself out of 21 points.
I got 18 out of 20, although a couple I just sort of went with my gut without thinking.
These kinds of things are fun, although I kind of prefer questions that edge a bit closer to practicality (like the one about “what output will this produce”).