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
What is a mixer? BTW NOT just any mixer....a mixer in music<br> THis is for tech theater class
ASHA 777 [7]

Answer:

it changes the level of music, such as bass level or sweter level

6 0
3 years ago
Which of the following includes premium content you must pay to use?<br> On word
kotykmax [81]

Some premium contents on Microsoft Word that you must pay before using them include:

  • 1 TB of OneDrive cloud storage
  • Advanced security
  • Expanded technical support
  • Premium templates, among others.

<h3>What are Premium Contents or Features?</h3>

Premium contents or features are exclusive features that have higher quality when compared to the usual quality. In an application like Microsoft Word, there are premium contents or features that can only be used or made available when you subscribe.

Some premium contents on Microsoft Word that you must pay before using them include:

  • 1 TB of OneDrive cloud storage
  • Advanced security
  • Expanded technical support
  • Premium templates, among others.

Learn more about premium contents on:

brainly.com/question/24749457

5 0
2 years ago
Exercise 3.16.4: Happy Face Solita
enot [183]

first do a happy face and a circule thats it

7 0
3 years ago
What the difference between a samsung and a android​
Vesnalui [34]

Explanation:

Every Samsung is an example of an Android but not every android is an example of a Samsung. Androids are all phones or devices that are not made by Apple.

3 0
4 years ago
The VP of sales at universal containers requested that "Verbal Agreement" be added as a new opportunity stage. The Administrator
Ahat [919]

Answer:

D. Add the new value to the appropriate sales process.

Explanation:

7 0
4 years ago
Other questions:
  • The publisher tab in the application control allows you to manage the various certificates that are used to do what to binaries?
    8·1 answer
  • How does a color change if you add more gray to it
    7·1 answer
  • Why should you need to have skills and an understanding about programming?
    8·1 answer
  • If it is impractical to place guest users in a secure network, isolated from the production network by firewall barriers, then:
    14·1 answer
  • Which method of accessing FTP has the most limited capabilities?
    9·2 answers
  • Suppose two hosts, A and B, are separated by 20,000 kilometers and are connected by a direct link of R = 2 Mbps. Suppose the pro
    5·1 answer
  • What does it mean to clear a setting in a dialog box?
    14·1 answer
  • Write a program roman which converts numbers from decimal notation into Roman numerals. roman takes a single argument, a string
    10·1 answer
  • . Question 1. Given the following grammar S → aAb | bBA A → ab | aAB B → aB | b and for each of the following right sentential f
    12·2 answers
  • In an experiment in which participants sat in an office and then were asked to remember what they saw in the office, participant
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!