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
Paraphin [41]
4 years ago
6

Write a script named dif.py. This script should prompt the user for the names of two text files and compare the contents of the

two files to see if they are the same. If they are, the script should simply output "Yes". If they are not, the script should output "No", followed by the first lines of each file that differ from each other. The input loop should read and compare lines from each file, including whitespace and punctuation. The loop should break as soon as a pair of different lines is found.

Computers and Technology
1 answer:
mestny [16]4 years ago
8 0

Answer:

Following are the code to this question:

f1=input('Input first file name: ')#defining f1 variable that input file 1

f2=input('Input second file name: ')#defining f2 variable that input file 2

file1=open(f1,'r')#defining file1 variable that opens first files by using open method  

file2=open(f2,'r')#defining file1 variable that opens second files by using open method  

d1=file1.readlines()#defining d1 variable that use readlines method to read first file data

d2=file2.readlines()#defining d2 variable that use readlines method to read second file data

if d1==d2:#defining if block that check file data

   print('Yes')#when value is matched it will print message yes  

   exit# use exit keyword for exit from if block

for j in range(0,min(len(d1),len(d2))):#defining for loop that stores the length of the file  

   if (d1[j]!=d2[j]):#defining if block that check value is not matched

       print('No')#print the message "NO"

       print("mismatch values: ",d1[j]," ",d2[j])#print file values

Output:

please find the attached file.

Explanation:

code description:

  • In the above code, the "f1 and f2" variable is used for input value from the user end, in which it stores the file names. In the next step, the "file1 and file2" variable is declared that uses the open method to open the file.
  • In the next line, the"d1 and d2" variable is declared for reads file by using the "readlines" method.
  • Then, if block is used that uses the "d1 and d2" variable to match the file value if it matches it will print "yes", otherwise a for loop is declared, that prints files mismatch values.

You might be interested in
All banks follow the same guideline for determining if an applicant qualifies for a loan.
dimaraw [331]

Answer:

I think false

Explanation:

I don't really know but if you get it wrong I'm so deeply sorry

8 0
3 years ago
DJ Davon is making a playlist for an internet radio show; he is trying to decide what 1212 songs to play and in what order they
Alja [10]

There are some typos in this question as the numbers become too large and lead to undefined during calculations.

so the correct data is:

Songs = 12

Rock = 15

Blues = 20

Disco = 15

The answer & explanation for this question is given in the attachment below.

4 0
3 years ago
Brian's father drives a car that uses voice commands for navigation. Which Al application field is Brian's father using?
Aneli [31]
O.C speech recognition
8 0
3 years ago
What type of power flaw involves a fluctuation in voltage levels caused by other devices on the network or by EMI?
HACTEHA [7]

Answer:

noise is the correct answer for the above question.

Explanation:

  • The noise is a term which is a barrier in the network of communication. It forces the signals to make a delay in data transfer. It is caused by any device or mechanism.
  • For example, if any data is transferring, but some device makes fluctuation in wire, then the communication voltage is disturbed.
  • The above question asked about the term which born with the help of some devices and it caused the fluctuation in the voltage. So the term is known as noise.
4 0
4 years ago
How dependent are we on technology? ​
rusak2 [61]

very independent  : ) we use it for everything

3 0
4 years ago
Read 2 more answers
Other questions:
  • An intranet is a way for a company or organization to protect copyrighted and other important information?
    15·2 answers
  • A spreadsheet is a software program for storing, managing, and retrieving information. true or false?
    15·2 answers
  • How does acceleration differ from velocity?
    15·1 answer
  • At a minimum, your vehicle insurance policy must provide coverage of
    10·1 answer
  • If a touch screen chrome is not charging what is wrong with it
    13·2 answers
  • Hello im looking for someone to answer my question. Its about a coding project called "Quiz Master". Im having trouble with the
    7·1 answer
  • Which of the following things can
    6·2 answers
  • Which of the following is not a benefit provided by a stakeholder analysis document
    7·1 answer
  • It is important to consider the quality of the data being used when considering the accuracy of a conclusion. Incorrectly collec
    11·2 answers
  • Consider the following method:
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!