# Program to demonstrate the use of lists to pass changes to parameters # back to the caller as return values # # Matt Bishop, MHI 289I, Fall 2021 # 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, "and outp =", outp) # change the value of the first element of outp outp = inp + 10 # announce the values to see if the change worked print("test ends: inp =", inp, "and outp =", outp) # return them return inp, outp # 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, "and b =", b) # now make the call a, b = testparam(a, b) # announce the values in the caller, after the call print("program ends: a =", a, "and b =", b)