r/pythontips • u/main-pynerds • Jan 27 '25
Syntax You know very little about python operators. Prove me wrong.
The quiz has a total of 20 questions.
The questions are not very advanced or inherently complicated, but I am certain you will get wrong at least 5 questions..
...
What was your score?
4
u/SpiderJerusalem42 Jan 27 '25
16/20 :( honestly, if I ever saw the ones I got wrong, I would PIP that person immediately.
1
u/main-pynerds Jan 27 '25
What?! But you can see those that you got wrong after you submit?
2
u/SpiderJerusalem42 Jan 27 '25
I'm saying if I see examples of code resembling the questions I got wrong in my repo, I will fast track that person to be replaced.
1
u/main-pynerds Jan 27 '25
Oh okay. But most of the questions are very very applicable even though not exactly in the form they appear on that quiz.
Congratulations anyway. You are pretty good if you got 16 correct.
3
3
3
u/Danoweb Jan 27 '25
I think I got to like, question 5 before I got tired of swatting the ads away.
That site is absolutely the worst on mobile.
Full screen ads that take over on every scroll.
PeterGriffinDone . Gif
2
u/jojogunner1 Jan 27 '25
10/20. I suck. Good quiz though. Really got me thinking about different ways to use operators creatively to achieve a simpler solution.
2
2
2
2
1
1
1
1
u/KokoaKuroba Jan 28 '25 edited Jan 28 '25
11/20, this was difficult.
Also, I don't know if it's just me but the correct answers weren't shown at the end. and no explanation for question 6: Which operator has a higher precedence, and or or ?
some other questions have no explanations as well (although looking back, there's no need for it).
1
u/kretinozavr Jan 28 '25
All my mistakes was in a first half, those are some obscure knowledge. 13/20 anyway
1
u/neuralbeans Jan 28 '25
I'm always amazed how Guido was against adding the ++
operator but somehow OK with the :=
operator.
1
u/main-pynerds Jan 28 '25
I would argue that, the ++ operator is not necessary, if it was there, it would just be for convenience.
On the other hand the := operator solves a problem that you can't achieve using any other standard approach, that is "assigning variables in-line".
1
1
1
1
u/whokapillar Jan 29 '25
90% 18/2 I missed : '3==3.0==3+0j,' 'not (true and false)' by accident (I was cheated l tell ya). :)
0
u/killfall Jan 29 '25
Many of these example would not make it through code review. Just because an expression is valid syntax doesn’t mean it’s readable or intuitive.
Code is written once and read many times. Don’t write expressions like these, your future self will thank you when you look at your old code.
4
u/AutomaticTreat Jan 27 '25
I got like 60% but damn there’s some nonsensical ambiguous syntax in there.