Logo

Question preview

If Christopher Nolan invented Python

What this preview is

About this preview

If Christopher Nolan invented Python 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.

What this Python scoping and execution-order question tests

This is a medium-difficulty Python question that probes your understanding of name resolution, scope binding, and the order in which Python evaluates assignments and function definitions. It rewards precise mental execution over guessing.

To solve it, you need to trace how Python builds its namespace at module load time, distinguish between the moment a function is defined and the moment it is called, and understand how variable lookups resolve across local, enclosing, and global scopes. The question tests whether you can reliably predict runtime behaviour without running the code — a skill that matters when debugging or reasoning about code correctness in interviews.

  • Global vs. local scope and the LEGB rule
  • Closure and late binding of free variables
  • The timing of function definition vs. execution
  • How Python resolves names at runtime