# # A program that shows that list members value might be changed # in a function + testing # # function 'square' squares all the elements of the list x # def square(x): n=len(x) for i in range(n): x[i]=x[i]*x[i] def test1(): print("TEST1") x = [1,2,3,4,5] print("the input list: ",x) y = x.copy() square(y) print("the list after 'square' call: ",y) for i in range(len(x)): if y[i] == x[i]**2: print("\t passed") else: print("\t failed on i = ",i) def test2(): print("TEST2") x=[0,0,0] print("the input list: ",x) square(x) print("the list after 'square' call:",x) for item in x: if item == 0: print("\t passed") else: print("\t failed on i = ",i) def test3(): print("TEST3") x = [-1,-2,-3] print("the input list: ",x) y = x.copy() square(y) print("the list after 'square' call:",y) for i in range(3): if y[i] == x[i]**2: print("\t passed") else: print("\t failed on i = ",i) test1() test2() test3()