The document demonstrates variable scope in Python by defining variables both locally and globally. It assigns strings to variables x, y, and z and prints x. It then defines a global variable x and function myfunc() that prints x, showing the global scope. Another section uses the global keyword in myfunc() to modify the global x. The last part defines a local x in myfunc(), showing that the local x hides the outer x in the print statement.
The document demonstrates variable scope in Python by defining variables both locally and globally. It assigns strings to variables x, y, and z and prints x. It then defines a global variable x and function myfunc() that prints x, showing the global scope. Another section uses the global keyword in myfunc() to modify the global x. The last part defines a local x in myfunc(), showing that the local x hides the outer x in the print statement.
The document demonstrates variable scope in Python by defining variables both locally and globally. It assigns strings to variables x, y, and z and prints x. It then defines a global variable x and function myfunc() that prints x, showing the global scope. Another section uses the global keyword in myfunc() to modify the global x. The last part defines a local x in myfunc(), showing that the local x hides the outer x in the print statement.