How Python Actually Behaves · Basics
How Python Actually Behaves — Basics
20 practice questions on How Python Actually Behaves. Every question is written from a specific moment in a real lecture, and after you answer it links to that exact timestamp so you can check it yourself.
What this pack asks
The free questions in this pack. Answer choices and explanations appear as you play.
A generator opens a resource in a with block and yields inside it. To watch what happens when a caller breaks out of the loop early, the yield is wrapped: … Why does keeping that bare raise matter?
Answer this one →A script filters a very large sequence and only needs entries up to the first match. One version writes list(filter(None, data))[0]; another loops over filter(None, data) directly and breaks. Why is the direct loop the better fit here?
Answer this one →A function memoizes results in a dict, building each key from the arguments. Using key = [user_id, tags] raises an error when it's used as a dict key, but key = (user_id, tuple(tags)) works fine. What accounts for the difference?
Answer this one →
Written from lectures by mCoding. Not affiliated with or endorsed by any university, channel, creator or certification program.