Start på pass 2

This commit is contained in:
2018-03-15 14:52:03 +01:00
parent ad6bc8642e
commit c39eae4ef4
6 changed files with 96 additions and 0 deletions

22
Pass2/scope.py Executable file
View File

@@ -0,0 +1,22 @@
def scope_test():
def do_local():
spam = "local spam"
def do_nonlocal():
nonlocal spam
spam = "nonlocal spam"
def do_global():
global spam
spam = "global spam"
spam = "test spam"
do_local()
print("After local assignment:", spam)
do_nonlocal()
print("After nonlocal assignment:", spam)
do_global()
print("After global assignment:", spam)
scope_test()
print("In global scope:", spam)