Lecture Notes on 14 Apr 2014 import random # compute the scalar product of two vectors def dot_product (a, b): sum = 0 for i in range (len(a)): sum += a[i] * b[i] return sum # sum the rows in a 2-D list def sum_rows (a): for row in a: sum = 0 for col in row: sum += col print (sum) # add two compatible matrices def matrix_add (a, b): c = [] for i in range (len(a)): d = [] for j in range (len(a[0])): d.append (a[i][j] + b[i][j]) c.append (d) return c def main(): # create a 2-D list (3 x 5) and fill with random numbers b = [] for i in range (3): c = [] for j in range (5): c.append (random.randint(1, 100)) b.append (c) # find the range in that 2-D list max_num = b[0][0] min_num = b[0][0] for row in b: for col in row: if (col > max_num): max_num = col if (col < min_num): min_num = col extent = max_num - min_num main()