-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathMatrix.py
More file actions
60 lines (43 loc) · 1.65 KB
/
Matrix.py
File metadata and controls
60 lines (43 loc) · 1.65 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class MATRIX():
def __init__(self,count):
self.count = int(count)
self.mat = MATRIX.Insert(self)
def Main():
pass
def Insert(self):
print("------------------Enter numbers row wise------------------\n")
block=[]
cblock=[]
for i in range(self.count):
cblock=[]
for j in range(self.count):
cblock.append(int(input()))
block.append(cblock)
MATRIX.Show(block,self.count)
return(block)
def Show(view,size):
print("----"*size)
for i in range(size):
print(view[i])
print("----"*size)
def ConstQuot(self,const,row):
for i in range(self.count):
self.mat[row-1][i] = self.mat[row-1][i] / const
MATRIX.Show(self.mat,self.count)
def ConstProd(self,const,row):
for i in range(self.count):
self.mat[row-1][i] = self.mat[row-1][i] * const
MATRIX.Show(self.mat,self.count)
def ConstDiff(self,const,row):
for i in range(self.count):
self.mat[row-1][i] = self.mat[row-1][i] - const
MATRIX.Show(self.mat,self.count)
def ConstSum(self,const,row):
for i in range(self.count):
self.mat[row-1][i] = self.mat[row-1][i] + const
MATRIX.Show(self.mat,self.count)
matrix1=MATRIX(input("------------------Enter the no of rows of the matrix------------------\n"),)
MATRIX.ConstSum(matrix1,3,1)
MATRIX.ConstDiff(matrix1,3,2)
MATRIX.ConstProd(matrix1,3,1)
MATRIX.ConstQuot(matrix1,3,2)