-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path3.py
More file actions
41 lines (29 loc) · 762 Bytes
/
3.py
File metadata and controls
41 lines (29 loc) · 762 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
30
31
32
33
34
35
36
37
38
39
40
41
def getVector(matrix, getRow):
result = []
for i in matrix:
result.append(getRow(i))
return result
def printBy(array, amount=5):
line = ""
for key, value in enumerate(array):
line += str(value) + " "
if (key + 1) % amount == 0:
print(line)
line = ""
print(line)
n = int(input("Set size of matrix..."))
matrix = []
for i in range(0, n):
matrix.append([])
for j in range(0, n):
matrix[i].append(int(input()))
a = int(input("Set a..."))
b = int(input("Set b..."))
def getVectorRow(row, a=a, b=b):
result = 0
for i in row:
if a <= abs(i) <= b:
result += i * i
return result
result = getVector(matrix, getVectorRow)
printBy(result, 5)