Logo

Question preview

Assign to what?

What this preview is

About this preview

Assign to what? is a medium quant interview question on language knowledge in Python.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

Understanding Python assignment and scope in this medium-difficulty question

This medium-difficulty Python question tests your grasp of how assignment statements interact with scope, variable binding, and the execution model. It's the kind of question that separates candidates who have read the language spec from those who've only written code intuitively.

To answer correctly, you need to trace through the code step by step, paying close attention to when names are bound to objects, how scope rules apply, and whether any runtime errors occur before or during assignment. Python's execution model—particularly the distinction between assignment, lookup, and mutation—matters here.

  • Local vs. global scope and the global keyword
  • Unbounded variable references and UnboundLocalError
  • How assignment affects name resolution in the current scope
  • When errors are raised during parsing vs. execution