What is the output of the following code, and why?
>>>X = 'Spam'>>>def func():print(X)>>>func()
What is the output of this code, and why?
>>>X = 'Spam'>>>def func():X = 'NI!'>>>func()>>>print(X)
What does this code print, and why?
>>>X = 'Spam'>>>def func():X = 'NI'print(X)>>>func()>>>print(X)
What output does this code produce? Why?
>>>X = 'Spam'>>>def func():global XX = 'NI'>>>func()>>>print(X)
What about this code—what’s the output, and why?
>>>X = 'Spam'>>>def func():X = 'NI'def nested():print(X)nested()>>>func()>>>X
How about this example: what is its output in Python 3.X, and why?
>>>def func():X = 'NI'def nested():nonlocal XX = 'Spam'nested()print(X)>>>func()
Name three or more ways to retain state information in a Python function.