python - Transpose of a matrix and printing result in same format -


write python function transpose (m) takes input 2 dimensional matrix using row wise representation , returns transpose of matrix using same representation

eg. assume input non empty matrix

>>>transpose ([[1,4,9]])  [[1] , [4], [9]]  >>>transpose  ([[1,3,5], [2,4,6]])  [[1,2], [3,4] , [5,6]] 

yeh! new python can

you should try numpy this. has transpose function. docs:

>>> x = np.arange(4).reshape((2,2)) >>> x array([[0, 1],        [2, 3]]) >>> np.transpose(x) array([[0, 2],        [1, 3]]) >>> x = np.ones((1, 2, 3)) >>> np.transpose(x, (1, 0, 2)).shape (2, 1, 3) 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -