Strange behavior of python's exec function
===

I think that below code fully describes the problem. Why in the Test2 function x has not been defined?

    >>> def Test1():
	exec('x=2')
	print(str(x))

	
    >>> Test1()
    2
    >>> def Test2():
	global x
	exec('x=2')
	print(str(x))

	
    >>> Test2()

    Traceback (most recent call last):
    File "<pyshell#39>", line 1, in <module>
    Test2()
    File "<pyshell#38>", line 4, in Test2
    print(str(x))
    NameError: global name 'x' is not defined