Skip to content

Commit 39a6de5

Browse files
committed
finished project
1 parent e6a98b5 commit 39a6de5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

linear-algebra/determinant-computation/determinant.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ def get_matrix():
1010
print(f'Enter the elements of the matrix {rows}x{cols}')
1111
matrix = []
1212
for i in range(rows):
13-
row = list(map(float, input(f'Row {i+1} (separate element with space): '))).split()
13+
row = list(map(float, input(f'Row {i+1} (separate element with space): ').split()))
1414
if len(row) != cols:
1515
raise ValueError('Number of elements does not match the number of columns!')
1616
matrix.append(row)
1717

1818
return np.array(matrix)
1919

20-
matrix = get_matrix()
20+
matrix = get_matrix()
21+
22+
try:
23+
determinant = np.linalg.det(matrix)
24+
print(f'Matrix: {matrix}')
25+
print(f'Determinant of the matrix: {determinant}')
26+
except ValueError as e:
27+
print(f'An error occurred {e}')

0 commit comments

Comments
 (0)