Computer Science

Which of the following is not correct in context of scope of variables ?

  1. Global keyword is used to change value of a global variable in a local scope.
  2. Local keyword is used to change value of a local variable in a global scope.
  3. Global variables can be accessed without using the global keyword in a local scope.
  4. Local variables cannot be used outside its scope.

Python Functions

3 Likes

Answer

Local keyword is used to change value of a local variable in a global scope.

Reason — If you need to modify a local variable in global scope, you do so by passing it as an argument to a function and/or returning a modified value from the function.

Answered By

1 Like


Related Questions