# Program to demonstrate the use of lists to pass changes to parameters # back to the caller through the argument list # # Matt Bishop, MHI 289I, Winter 2018 # this routine tries changes outp # parameters: inp, a list of one integer # outp, a list of one integer def testparam(inp, outp): # announce the values on entry to the function print "test begins: inp =", inp[0], "and outp =", outp[0] # change the value of the first element of outp outp[0] = inp[0] + 10 # announce the values to see if the change worked print "test ends: inp =", inp[0], "and outp =", outp[0] # call a function that changes parameter values # and see if the change is reflected in the caller # calls: testparam # set the values to be used; note these are *lists* a = [ 1 ] b = [ 2 ] # announce the values in the caller, before the call print "program begins: a =", a[0], "and b =", b[0] # now make the call testparam(a, b) # announce the values in the caller, after the call print "program ends: a =", a[0], "and b =", b[0]