Cumulation Please implement a python program to cumulate row-wise sums, column-wise sums, and total sum of input matrix of positive integers incrementally (i.e., without storing input matrix if the...

1 answer below »
Please see instructions for this assignment in attachments.


Cumulation Please implement a python program to cumulate row-wise sums, column-wise sums, and total sum of input matrix of positive integers incrementally (i.e., without storing input matrix if the matrix is huge). Your program should read all t3*.dat in the same directory as your p3.py, and generate output for each t3*.dat as the example below. You need handle whitespace as the whitespace convention and handle errors. Possible errors are: 1) input is not positive integers, and 2) number of columns are not the same for all rows. If a t3*.dat file contains errors, you need to print error message (e.g., “ERROR: t39.dat is not in correct format”) and exit from current file and try next file if there is one. You need to create all possible files to make sure your program works. Input Example:  1   2  3   4  5   6 Output Example:  1   2   3  3   4   7  5   6  11  9  12  21
Answered Same DaySep 11, 2021

Answer To: Cumulation Please implement a python program to cumulate row-wise sums, column-wise sums, and total...

Aditya answered on Sep 12 2021
150 Votes
def checkfile(file):
f = open(i, 'r')
line = f.readlines()
temp = []
flag = 0
for j in line:
j = j.split()
temp.append(j)
try:
for k in range(len(j)):
j[k] = int(j[k])
except Exception:
print(i,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here