What will be the output of the following Python program?

x = 10

def test():
    x = 20

test()
print(x)
                        

Options

  • A. 20
  • B. 10
  • C. None
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. 10

Detailed Explanation

The variable x inside the function is local. It does not modify the global variable.