Observe the Python code carefully and answer the following question : Identify…

2023

Observe the Python code carefully and answer the following question : Identify the global identifier in the above code:

image.png

  1. A.

    A / A

  2. B.

    L / L

  3. C.

    i / i

  4. D.

    N / N

Attempted by 1265 students.

Show answer & explanation

Correct answer: D

Answer: N is the global identifier.

Reason: N is assigned at the top level with the statement N = 10, which is outside any function. That makes N a module-level (global) name. The other identifiers are defined inside the function and are local.

  • A: This is the function parameter (FUN(A)), so it is local to the function.

  • L: This list is created inside the function with L = [], making it a local variable.

  • i: This is the loop variable in for i in range(2, A); it exists only within the function's scope.

  • N: Assigned at module level (N = 10), so it is global. Calling FUN(N) passes its value into the function but does not change its global status.

Explore the full course: Rssb Senior Computer Instructor