Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 39a6de5

Browse filesBrowse files
committed
finished project
1 parent e6a98b5 commit 39a6de5
Copy full SHA for 39a6de5

File tree

1 file changed

+9
-2
lines changed
Filter options

1 file changed

+9
-2
lines changed

‎linear-algebra/determinant-computation/determinant.py

Copy file name to clipboardExpand all lines: linear-algebra/determinant-computation/determinant.py
+9-2Lines changed: 9 additions & 2 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.