Local variables (2)

Variables created in a function are local variables:

  • they are not known outside the function

  • they do not affect variables outside the function

Running this program

def aFunction():
  n = 0
  print "n inside the function:", n

n = 100
aFunction()
print "n outside the function:", n

prints:

n inside the function: 0
n outside the function: 100