2.1.7 Exercises


#1

Heyaa all !
I wanted to discuss answers of each and every exercises, as solving and discussing makes learning two way process.
Answer 1: Given x < y or x > y
array([[ True, False, True, False],
[False, False, False, False],
[False, False, False, False]])
array([[False, False, False, False],
[ True, True, True, True],
[ True, True, True, True]])
#Here False is 0 and True is 1

Answer 2:
e= np.arange(3).reshape((3,1,1))
f=np.arange(2).reshape((1,2,1))
e,f
e+f
array([[[0],
[1]],

   [[1],
    [2]],

   [[2],
    [3]]])

Answer 3:

a=np.arange(12).reshape(4,3)
b=np.arange(6).reshape(2,3)
c=np.arange(8).reshape(4,2)
c += np.dot(a, b.T)
c
array([[ 5, 15],
[ 16, 53],
[ 27, 91],
[ 38, 129]])

‚Äč
Suggestions are welcome.
Thank you!