1- # Wikipedia URL- https://en.wikipedia.org/wiki/Determinant
2-
31def get_minor (matrix : list [list [int ] | list [float ]], row : int , col : int ) -> list [list [int ] | list [float ]]:
42 """
53 Returns the minor matrix obtained by removing the specified row and column.
@@ -9,14 +7,21 @@ def get_minor(matrix: list[list[int] | list[float]], row: int, col: int) -> list
97 matrix : list[list[int] | list[float]]
108 The original square matrix.
119 row : int
12- The row to remove.
10+ Row to remove.
1311 col : int
14- The column to remove.
12+ Column to remove.
1513
1614 Returns
1715 -------
1816 list[list[int] | list[float]]
1917 Minor matrix.
18+
19+ Examples
20+ --------
21+ >>> get_minor([[1,2],[3,4]], 0, 0)
22+ [[4]]
23+ >>> get_minor([[1,2,3],[4,5,6],[7,8,9]], 1, 1)
24+ [[1, 3], [7, 9]]
2025 """
2126 return [r [:col ] + r [col + 1 :] for i , r in enumerate (matrix ) if i != row ]
2227
@@ -37,12 +42,14 @@ def determinant_manual(matrix: list[list[int] | list[float]]) -> int | float:
3742
3843 Examples
3944 --------
40- >>> determinant_manual([[1,2],[3,4]])
41- -2
4245 >>> determinant_manual([[2]])
4346 2
47+ >>> determinant_manual([[1, 2], [3, 4]])
48+ -2
4449 >>> determinant_manual([[1,2,3],[4,5,6],[7,8,9]])
4550 0
51+ >>> determinant_manual([[3,0,2],[2,0,-2],[0,1,1]])
52+ 10
4653 """
4754 n = len (matrix )
4855
0 commit comments