Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »
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 e
ors. Possible e
ors 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 e
ors, you need to print e
or message (e.g., “ERROR: t39.dat is not in co
ect format”) and exit from cu
ent 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 Day Sep 11, 2021

Solution

Aditya answered on Sep 12 2021
151 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