Lecture Notes on 14 Oct 2009 # This function returns the sum of the elements in a 1-D list def sumList (a): sum = 0 for item in a: sum = sum + item return sum # Alternative solution sum = 0 for i in range (len(a)): sum = sum + a[i] return sum # This function returns the sum of the elements in a 2-D list def sumList (a): sum = 0 for row in a: for col in row: sum = sum + col return sum # Alternative solution sum = 0 for i in range (len(a)): for j in range (len(a[i])): sum = sum + a[i][j] return sum # This function returns the maximum of the elements in a 1-D list def getMax (a): max = a[0] for i in range (1, len(a)): if (a[i] > max): max = a[i] return max # This function returns the maximum of the elements in a 2-D list def getMax (a): max = a[0][0] for i in range (len(a)): for j in range (len(a[i])): if (a[i][j] > max): max = a[i][j] return max