Skip to content

Commit ac07da8

Browse files
committed
Update Matrix
1 parent 00d4bc5 commit ac07da8

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Python/Matrix/index.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
matrix = [[0 for i in range(4)] for j in range(3)]
2+
3+
print(matrix)
4+
5+
var_matrix = [[1, 2, 3, 4, 5],
6+
[6, 7, 8, 9, 10],
7+
[11, 12, 13, 14, 15],
8+
[16, 17, 18, 19, 20],
9+
[21, 22, 23, 24, 25]]
10+
11+
print(var_matrix[3][3])

Python/Matrix/operations.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import numpy as np
2+
3+
# matrix 2x2
4+
matrix = [[9, 0],
5+
[8, -5]]
6+
7+
def_matrix = [[0 for i in range(2)] for j in range(2)]
8+
9+
for i in range(len(matrix)):
10+
for j in range(len(matrix[0])):
11+
def_matrix[i][j] = matrix[i][j] * 2
12+
13+
print(def_matrix)
14+
15+
# matrix 2x2 using NumPy
16+
var_matrix = np.array([[9, 0],
17+
[8, -5]])
18+
19+
result_matrix = var_matrix * 2
20+
21+
print(result_matrix)

0 commit comments

Comments
 (0)