CMU 15-112 Spring 2016 Quiz 6 Practice: Code Tracing (2 of 2)
(Due never)



# Code Tracing #1 of 2 import copy def p(a): return [a[row][0] for row in range(len(a))] def ct1(a): (b, c) = (copy.copy(a), copy.deepcopy(a)) a[0] = b[1] b[2] = c[0] c[1] = a[2] a[0][0] = 7 b[2][0] = 8 c[1][0] = 9 print(p(a), p(b), p(c), end = " ") a = [[4], [5], [6]] ct1(a) print(p(a))

# Code Tracing #2 of 2 def ct2(a): (rows, cols) = (len(a), len(a[0])) result = [0]*rows for row in range(rows): for col in range(0,cols,2): #note the range! result[row] += a[rows-1-row][col] # note indices! return result print(ct2([[1,2,3,4,5], [2,4,6,8,10]]))