Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. What happens if a local variable exists with the same name as the global variable you want to access?
  2. A.
    Error
    B.
    The local variable is shadowed
    C.
    Undefined behavior
    D.
    The global variable is shadowed

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    If a local variable exists with the same name as the local variable that you want to access, then the global variable is shadowed. That is, preference is given to the local variable.


Be The First To Comment