We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9605dcb commit 43a9fe5Copy full SHA for 43a9fe5
programs/transpose_of_matrix.py
@@ -0,0 +1,22 @@
1
+class Matrix(object):
2
+ def __init__(self,mat = None):
3
+ self.mat = mat
4
+
5
+ def get_matrix(self) -> list:
6
+ return self.mat
7
8
+ def transpose(self) -> list:
9
+ if self.mat:
10
+ try:
11
+ return list(zip(*self.mat))
12
+ except Exception as e:
13
+ return f"Failed to convert transpose because {e}"
14
+mat = [
15
+ [1,2,3],
16
+ [4,5,6],
17
+ [7,8,9]
18
+ ]
19
20
+matrix_obj = Matrix(mat)
21
+print(f"Original Matrix is : \n {matrix_obj.get_matrix()}")
22
+print(f"Transpose of above matrix is : \n {matrix_obj.transpose()}")
0 commit comments