-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpratice.py
More file actions
29 lines (21 loc) · 712 Bytes
/
pratice.py
File metadata and controls
29 lines (21 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
test = [[1,1,0,0,1],[1,1,0,1,0],[0,0,1,1,0],[0,1,1,1,1],[1,0,0,1,1]]
test_transfer = []
def matrix_trasfer(origin, transfer):
for i in range(len(origin)):
transfer.append([])
for j in range(len(test)):
transfer[i].append(origin[j][i])
print test_transfer
def matrix_multi(origin, transfer):
result_matrix = []
total = 0
for k in range(len(origin)): # k = origin_row
result_matrix.append([])
for i in range(len(origin)): # i = transfer_row
for j in range(len(origin[0])): # j = origin&transfer_col
total = total + origin[k][j]*transfer[i][j]
result_matrix[k].append(total)
total = 0
print result_matrix
matrix_trasfer(test, test_transfer)
matrix_multi(test, test_transfer)