Question: A matrix can be reprsented in Python as a list of lists. For example, the matris 2 5 an be 1 -2 0 represented in

 A matrix can be reprsented in Python as a list of

A matrix can be reprsented in Python as a list of lists. For example, the matris 2 5 an be 1 -2 0 represented in Python as the list L-[t1,-2,0], 0,2,5], (2,-9,61] To access the u.i)th element of the matrix, use the Python syntax L[1] [j]. (Remember that Python starts numbering at 0, so L[2] [1] for example.) -9 6 --9 (a) Write a Python function read.matrix(tile) to read a matrix from a file and return the matrix as a of lists. Assume the matrix is n n. The first line of the file will be the value of n. Each subequent line will contain one row of the matrix. So for the example above, the input file ill look like: 1-2 0 025 2-9 6 (b) Write a Python function matrix2CA) to compute and return the square of a matrix (as a list of listas) where A is a matrix stored as a list of lists. Given a matrix A, the square of A is simply A A, or A The square of a matrix is defined only if the matrix has the same number of rows as columns, so your function should check for this. Your function should not alter the original matrix. The (ij)th entry of the square of an n x n matrix A is computed as 1 -6 10 For the matrix above, the square is 10 41 40 14 76 -9 (c) Write a Python function matrix.aum(A,B) to compute and return the sum of two matrices (as a list of lists) which the matricies A and B are stored as a list of lists. The sum is defined only if the two matrices have the same size, so your function should check for this. The (i,j)h entry of the sum of A and B is computed as ay t by. Your function should not modify either of the input matrices. (d) Write a Python function matrix.rov(A) to stin the rows of a natrix A Your function shot.ld return a list in which the it entry is the sum of the ih row of the input matrix A. LG

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 Databases Questions!