def scalar_product(x, y, dimension): sum = 0.0 for i in range(dimension): sum += x[i]*y[i] return sum