= 5 # a is a global variable
a = a + 1 # b is a global variable
b
def fun(d): # d, as a parameter, is a local variable
= 7 + a + d # c is a local variable
c print(c)
1) fun(
13
Every Python variable has a scope, defining where it is created and who/when this variable can be accessed
GLOBAL SCOPE: all functions have access to them.
LOCAL SCOPE: only the function who created it has access to it
a = 5 # a is a global variable
b = a + 1 # b is a global variable
def fun(d): # d, as a parameter, is a local variable
c = 7 + a + d # c is a local variable
print(c)
fun(1)
13