Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1.1 Q1.2 Q1.3 Q.2 In this question, you are going to write methods that operate on matrices. The program reads values of matrices A, B,

image text in transcribedQ1.1
image text in transcribedQ1.2
image text in transcribedQ1.3
image text in transcribedQ.2
In this question, you are going to write methods that operate on matrices. The program reads values of matrices A, B, and stored in a file called inputs.txt. This file should be placed under current directory where you have the program. The first line before each matrix contains the number of rows and the number of columns as shown below. Import randon Import sys Get readtrix ruberofrons underofColumns, tile): natrix.i.Cate antys for rox in range(berofus): matrix.open(t)) Anempty w now rowdata. (int(*) for in line.split("")) for column in rangenter of Columns) natrix[row).append(rondata[column)) return matrix del printmatrix(catrix): for ror in rangelen (matrix) for column in rangellenmatrix[ro])): print(format (natrix[row]column),"5"), end print() Printer time def Fellatrixdonly[underoftous, tuberofColumns ) natrix create onesty to for row in range(beroflow): matrix.end(11) Antyw for colum in rerumber of Columns): natrixtrow.opend randon.randintco. >>>> return atrix def generateZeroRate interfrows, rusterOfColumns): ") natraffer : tn range(number ofrot) or in range(number of Columns) ] return def ,6) c. generateromatrix (4), tento for row in rangellen(A)): for column in rangeltrow]>> ctronicelun] . Atrow][column][row column return #Redtrect standard output device (console) to output txt file #print statements will write to output.txt file sys.stdout .open('output.txt*, ') print("Wreating data from Inputs, txt file in current directory!) line fredline) unberotonerofColumns (int (for in the 911 , print("trix A printmatrix(A) ) uberoflors, berotolumns - fant) for 2 to 11.1918 Breadtrixbertos, nuber of Columns, print. Ratrix pritaria) teau line.f.readline riunberoflot, cumberOfColumns - [310(x) for in line.split("")) (readtrunberorrows, ber of Columns, print printf(C) o filtrandoleterotrows, uberofColumns) print(atrix print(0) print(" *** Computing (1) Transpose())) - A) Tada (A) print(" **** Matrix (A) ***** printers) write the rest of code sin( You are going to write the code for the following methods and the missing code in mainl). det multiply, def transpose() def worElements (A) def subtractatris. >> The program will calculate 5 = {A+B) * Transpose(C) - A) +D and find the maximum element in S. Complete the code given above so that it will produce an output as follows:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

=+ Are they breakable for any reason?

Answered: 1 week ago

Question

=+When and under what circumstances are contracts renegotiated?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago