Analyze a Python program to remove all global variables and replace them with local variables.
a = 1
def foo():
 print(a)

def bar():
 global a
 a = 2

foo()
bar()
def foo():
 a = 1
 print(a)

def bar():
 a = 2

foo()
bar()