QuestionQ206

VerifiedFunctions and Exceptions

What is the expected output from the following code?

Question Image

Explanation

The global y declaration makes the assignment inside func update the module-level variable y. Calling func(2) sets y to 4, so print(y) outputs 4.

Community Discussion

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