Answers
2.4. Answers#
Solution to Exercise 2.1
1.0(float)1(int)TypeErrorsincex/xis a float and we cannot index an array using a float. Try usingz[x//x]orz[int(x/x)]instead."5555555555"(string)[10, 20, 10, 20, 10, 20, ... , 10, 20](list)TypeErrorsince 10. is a float and we cannot use the operator*with a list and a float. First convert to a float.array(100, 200)(Numpy array)TypeErrorsince floats and strings cannot be added. Convertwto an int or float first e.g.y + int(w).array([100, 400])Numpy performs elementwise multiplication