# Practical 1

FOA Practical
unknown
python
a year ago
1.2 kB
2
Indexable
Never
```import time
start=time.time()
start_time=time.ctime(start)
print("The number of rows and columns in 1st matrix and 2nd matrix must be the same to perform Matrix Addition")
r1=int(input("Enter the number of rows in matrix: "))
c1=int(input("Enter the number of columns in matrix: "))
r2=r1
c2=c1
matrix1=[]
matrix2=[]
result=[[0 for i in range(c1)] for i in range(r1)]
print("Enter the values of 1st matrix:")
for i in range(r1):
a=[]
for j in range(c1):
print("Value at [",i+1,",",j+1,"]",": " )
a.append(int(input()))
matrix1.append(a)
print("Enter the values of 2nd matrix:")
for i in range(r2):
b=[]
for j in range(c2):
print("Value at [",i+1,",",j+1,"]",": " )
b.append(int(input()))
matrix2.append(b)
for i in range(r1):
for j in range(c2):
result[i][j]=matrix1[i][j]+matrix2[i][j]
print("Matrix 1 is : ")
for i in matrix1:
print(i)
print("Matrix 2 is : ")
for i in matrix2:
print(i)
print("Matrix 1 + Matrix 2 is : ")
for i in result:
print(i)
end=time.time()
end_time=time.ctime(end)
print("\nTime Complexity")
print("The start time is: ", start_time)
print("The end time is: ", end_time)```