1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SOVA2 [1]
3 years ago
10

Design the program that reads two files and compares their contents. The program calls a method that reads the file one line at

a time. If the lines are the same the program skips the line. If the lines are different then the program prints the line number followed by the different lines from each file.
Computers and Technology
1 answer:
Advocard [28]3 years ago
5 0

Answer:

file1 = []

file2 = []

fileone = "lyric1.txt"

filetwo = "lyric2.txt"

def linereader( myfile, mylist):

   for line in open(myfile, "r") as file:

       line_read = readlines( line)

       mylist.append( line_read)

   file.close()

linereader( fileone, file1)

linereader( filetwo, file2)

# Assuming both files have same number of lines.

for index, item in enumerate(zip(file1, file2)):

   if item[0] != item[1]:

       print( index + 1, item)

Explanation:

The python code compares two files and returns the number and the lines from both files that do not match. The source code opens the files lyric1.txt and lyric2.txt reading each lines to different lists which are iterated to compare its items returning the number of the line and the unequal lines.

You might be interested in
Choose the words that make the following sentence true.<br> Primary memory is
ki77a [65]

Answer:

Primary memory is computer memory that is accessed directly by the CPU

Explanation:

8 0
3 years ago
How does the speaker feel about traditional forms of poetry
Salsk061 [2.6K]
A speaker sometimes is not able to capture the intended details since it is affected by homophones.
7 0
3 years ago
Read 2 more answers
Put these operating systems in order according to the date they were released. (The first to be released would be
uysha [10]
1. ms-dos 1981
2. windows 2.0 1987
3. windows xp 2001
4. mac os 2001
5. windows 7 2009
8 0
3 years ago
Write a loop statement to count and display the number of positive integers in the array. That is, your loop should display the
dlinn [17]

Answer:

int count =0;

    for(int i=0;i<10;i++)

    {

        if(myArray[i]>=0)

        {

            count++;

        }

    }

    cout<<"Number of positive integers is "<<count<<endl;

Explanation:

The above written loop is for counting positive integers in the myArray[].

For counting we have taken a count integer initialized with 0.On iterating over the array if the element is greater than or equal to 0 we consider it as positive and increasing the count.At the end printing the count.

3 0
3 years ago
Sarah believes that thanks to the ability of science and technology to create progress problems will be solved and life will imp
TEA [102]

Answer:

Sarah would best be described as a modernist

Explanation:

A modernist is a person who believe or follow new way of doing things, it could be art work or science and technology. Sarah's believe on science and technology of creating modern way of making progress in problem solving qualifies her to be described as a Modernist.

4 0
3 years ago
Other questions:
  • Stefan is finalizing his presentation by adding media files and preparing it for distribution. Stefan knows that saving a presen
    13·1 answer
  • What is the full word of"VPN"?​
    15·2 answers
  • What is hyper transport
    10·1 answer
  • Why when I move stuff in Roblox Studio like an object or a Character. It tilts the opposite direction I'm moving it to with the
    6·2 answers
  • ___ involves connecting geographically remote computers into a single network and combining the computational power of all compu
    14·1 answer
  • Seeing an error message on the screen after you click on a link or icon may indicate that your PC doesn't have the correct _____
    15·1 answer
  • 1)Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "positive" otherwise. Examp
    15·2 answers
  • Mark and his team are working on a project that is due for delivery in the next few days. The team is using project management t
    10·1 answer
  • Which is a linear presentation?
    10·1 answer
  • What is the accurate description
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!