Question: ( Algebra: add two matrices ) Write a function to add two matrices. The header of the function is: def addMatrix ( a , b

(Algebra: add two matrices)
Write a function to add two matrices. The header of the function is:
def addMatrix(a, b):
In order to be added, the two matrices
and
must have the same dimensions and the same or compatible types of elements. Let
be the resulting matrix. Each element
is equal to
. For example, for two 3 by 3 matrices and
and
,
is:
Write a test program that prompts the user to enter two matrices and displays their sum. The numbers in each matrix are entered in one line. Here is a sample run:
Sample Run
Enter matrix1: 123456789
Enter matrix2: 02414.52.21.14.35.2
The matrices are added as follows:
1.02.03.00.02.04.01.04.011.0
4.05.06.0+1.04.52.2=5.011.58.2
11.08.011.01.14.35.28.112.314.2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!