QuestionQ70

VerifiedFunctions, Classes and Objects

What will the following Python 3 code produce?

Question Image

Explanation

Python uses lexical scope resolution. Since inner_func has no local variable named x, it reads the x defined in the enclosing outer_func; the later print in outer_func reads that same value.

Community Discussion

No comments yet. Be the first to start the discussion!