-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject30.py
44 lines (35 loc) · 882 Bytes
/
project30.py
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
from numpy import *
a1=int(input('number of rows='))
b1=int(input('number of columns='))
n1=a1*b1
A=matrix(zeros(n1,int).reshape(a1,b1))
for i in range(a1):
for j in range(b1):
x=int(input('enter value='))
A[i,j]=x
print('matrix A is:')
print(A)
a2=int(input('number of rows='))
b2=int(input('number of columns='))
n2=a2*b2
B=matrix(zeros(n2,int).reshape(a2,b2))
for i in range(a2):
for j in range(b2):
x=int(input('enter value='))
B[i,j]=x
print('matrix B is:')
print(B)
n3=a1*b2
C=matrix(zeros(n3,int).reshape(a1,b2))
if b1==a1:
n=b1=a2
for i in range(a1):
for j in range(b2):
x=0
for k in range(n):
x=x+A[i,k]*B[k,j]
C[i,j]=x
print('miltiplication is:')
print(C)
else:
print('multiplication not possible')