Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please include the not-required part into the program. Thank you. Make a new ver

ID: 3641568 • Letter: P

Question

Please include the not-required part into the program. Thank you.

Make a new version of your program for the previous problem, but this time, instead of storing the matrix directly in the source code of your program, have it read the 3 times 3 matrix from a file. Your program should take two command line arguments: the first should be an integer (1 or 2 specifying whether to sum columns or rows, as in the above question), and the second should be the filename to read from. Your program should be able to read files that have numbers in each row separated by spaces, with one row per line. For instance: Not required for your own practice: Modify your program to check that every row in the file has exactly 3 numbers, and to print an error message if one does not.

Explanation / Answer

import sys

print sys.argv[0]
print sys.argv[1]

theFile = open(sys.argv[1], "r")
theInts = []
for val in theFile.read().split():
theInts.append(int(val))

theFile.close()

theInts.sort()
print theInts
"""This is solution where i am reading a text file and putting in one-D array , it can be done in 2-D array also but i can understand the part where you are telling that first arg is integer and accordingly you have to do operation."""
if you want complete code then please write the complete question ... or if i haven't understand then explain me ...:)