S
COPE
def myfunc():
x = "Local Scope"
print(x)
myfunc()
x = "Function Inside Function"
def myinnerfunc():
print(x)
myinnerfunc()
myfunc()
def myfunc():
print(x)
myfunc()
def myfunc():
x = "Local Scope"
print(x)
myfunc()
def myfunc():
global x
x = 300
myfunc()
print(x)
def myfunc():
global x
print(x)
x = 200
print(x)
myfunc()
COPE
def myfunc():
x = "Local Scope"
print(x)
myfunc()
Local Scope
def myfunc():x = "Function Inside Function"
def myinnerfunc():
print(x)
myinnerfunc()
myfunc()
Function Inside Function
x = "Global Scope"def myfunc():
print(x)
myfunc()
Global Scope
print(x)
Global Scope
x = "Global Scope"def myfunc():
x = "Local Scope"
print(x)
myfunc()
Local Scope
print(x)
Global Scope
Global Keyworddef myfunc():
global x
x = 300
myfunc()
print(x)
300
x = 300def myfunc():
global x
print(x)
x = 200
print(x)
myfunc()
300
200
print(x)200
200
Comments
Post a Comment