Class - 12 CBSE Computer Science — Assertion Reason Type Questions

Assertion (A): Local Variables are accessible only within a function or block in which they are declared.

Reasoning (R): Global variables are accessible in the whole program.

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true but R is not the correct explanation of A.
  3. A is true but R is false.
  4. A is false but R is true.

Python Functions

3 Likes

Answer

Both A and R are true but R is not the correct explanation of A.

Explanation
Local variables have a limited scope and are accessible only within the function or block where they are defined. On the other hand, global variables have a broader scope and can be accessed from any part of the program, including functions and blocks.

Answered By

1 Like