Quizzma Latest Questions

What is the function namespace?

x = 10
def add_nums():
y = 2
z = x + y
print z

Function namespace
Global namespace
Object namespace
Class namespace




Related Questions

Leave an answer

Leave an answer

1 Answer

  1. The correct answer is Global namespace.

    In the provided code, the variable `x` is defined outside of the `add_nums()` function, making it part of the global namespace. This means it can be accessed inside the function. The variable `y` is defined within `add_nums()`, giving it function-local scope, while `z` is also local to that function. Therefore, `x` belongs to the global namespace, which is accessible from anywhere in the program. If you have more questions or need further clarification, feel free to ask!