Question: Computer Science I Compare Two Files CSCI-141 Homework 1 Task In this assignment you will compare two different files in Python. The comparison will be

 Computer Science I Compare Two Files CSCI-141 Homework 1 Task In
this assignment you will compare two different files in Python. The comparison
will be a line by line and character by character on each
line. Write a function, char by_char, that will compare two files character

Computer Science I Compare Two Files CSCI-141 Homework 1 Task In this assignment you will compare two different files in Python. The comparison will be a line by line and character by character on each line. Write a function, char by_char, that will compare two files character by character and print the umber of characters that are different. This is not a true full-file comparison. You will actually compare a line from one file to the line at the same location in the other file, character by character. Addition or removal of whole lines will not be detected. 1.1 Requirements Your function should take in two file names as parameters; assume both files exist. The char_by_char function will: . Read the next line from each file. If the lines are different lengths, report only the line umber and proceed to the next line in each file. If the lines are the same length, compare the lines character by character. . If the lines match completely, proceed to the next line in each file. . If they do not match, then for each line: Print Unmatched characters:' as a line label; and -print the number of the line and the first character position that does not match. Print this line information in N: M format, and use 1-based character positions (see examples); Then proceed to process the next line in each file. - .If one of the files has fewer lines than the other, the function reports the 'extra line(s) as non-matching. . Lastly, the function prints: - the number of characters in the first file; - the number of characters in the second file; -the number of characters that do not match in lines of the same length; and the number of lines that are not the same length. Note: Count all characters and spaces, but do not count newline characters. 1.2 Example Executions While out put does not have to match exactly, it should display the same information

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!