Computer Science

Assertion. A function declaring a variable having the same name as a global variable, cannot use that global variable.

Reason. A local variable having the same name as a global variable hides the global variable in its function.

Python Functions

2 Likes

Answer

(a)

Both Assertion and Reason are true and Reason is the correct explanation of Assertion.

Explanation
Inside a function, you assign a value to a name which is already there in global scope, Python won't use the global scope variable because it is an assignment statement and assignment statement creates a variable by default in current environment. That means a local variable having the same name as a global variable hides the global variable in its function.

Answered By

3 Likes


Related Questions