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
What is NOT a good habit when presenting to an audience?
soldier1979 [14.2K]
Read directly from the slides,
if your doing a project, you should have it memorized
8 0
3 years ago
Read 2 more answers
i have a bag of trail mix . one half of the bag is peanuts. 1/4 of the bag is chocolate candies , and 1/4 of the bag is died fru
Lelu [443]
In our bag, 1/2 is peanuts, 1/4 is chocolate and 1/4 is dried fruit.

The likelihood of drawing a chocolate therefore is 1/4. 

The likelihood of drawing a peanut is 1/2 and the likelihood of drawing a dried fruit is 1/4.

Thus, D is the correct answer because the 1/4 likelihood of drawing a chocolate is less than the 1/2 chance of drawing a peanut.
8 0
3 years ago
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space.
Ksenya-84 [330]

Answer:

   while(userNum>=1){

       System.out.print(userNum/2+" ");

       userNum--;

        }

Explanation:

This is implemented in Java programming language. Below is a complete code which prompts a user for the number, receives and stores this number in the variable userNum.

<em>import java.util.Scanner;</em>

<em>public class TestClock {</em>

<em>    public static void main(String[] args) {</em>

<em>    Scanner in = new Scanner (System.in);</em>

<em>        System.out.println("Enter the number");</em>

<em>    int userNum = in.nextInt();</em>

<em>    while(userNum>=1){</em>

<em>        System.out.print(userNum/2+" ");</em>

<em>        userNum--;</em>

<em>         }</em>

<em>    }</em>

<em>}</em>

The condition for the while statement is userNum>=1 and after each iteration we subtract 1 from the value of   userNum until reaching 1 (Hence userNum>=1)

3 0
3 years ago
What is the difference between throughput and bandwidth?
masha68 [24]

Answer: Please find below the answer along with explanation.

Explanation:

For  a given communication channel (for instance, a LAN segment using Ethernet ) the Bandwidth refers to the theoretical maximum data rate that the channel can support, for instance, 100 Mbps in a 100Base T network.

The throughput, instead, refers to the actual data rate achieved in a given communications channel, taking into account the different channel impairments.

For instance, in a LAN segment that uses the original Ethernet 802.3 standard (CSMA/CD), a frequent occurrence of collisions can take down the actual data rate from the theoretical 100 Mbps to a very lower figure, i.e., 5 Mbps.

4 0
3 years ago
Manipulate the SQL statement to pull ALL fields and rows from Customers table that have a PostalCode of 44000. TIP: Since Postal
padilas [110]

Answer:

There are two customers in the PostalCode.

SQL statement for select all the fields and the rows from the Customers table where PostalCode is 44000.

SELECT *  FROM Customers  WHERE PostalCode = "44000";

Explanation:

The SELECT statement retrieve zero or more than one row from 1 or more than one the database tables or the database views.  

In most of the applications, the SELECT query is most commonly used for DQL(Data Query Language) command.  

SQL is the declarative programming language and the SELECT statement specifies the result set, but they do not specifies how to calculate it.

6 0
2 years ago
Other questions:
  • To type the letter address, _________ space from the dateline
    9·2 answers
  • Translate each of these statements into logical expressions using predicates, quantifiers, and logical connectives. a) Something
    7·1 answer
  • You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store
    10·1 answer
  • What is one way to recognize whether an online source has been copyrighted? The source features the phrase “all rights reserved.
    6·2 answers
  • What do the following standards cover?
    7·1 answer
  • What is GIGO ?<br>plz answer me​
    7·1 answer
  • Use the {blank} to view your presentation the way an audience will see it.
    13·2 answers
  • State the Limitations of the first generation of computers​
    8·1 answer
  • When we look for errors inside of our code on our own or with a partner , what is that called?
    9·2 answers
  • What causes the hidden node problem in a wireless local area network (wlan)?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!