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]
3 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]3 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
Which are examples of hardware? Select 3 options.
umka21 [38]

Answer: OS(Operating System), CPU, And The Program That you use to view email

6 0
2 years ago
Read 2 more answers
What type would the object X be in the following statement:
Y_Kistochka [10]

Answer:

Boolean

Explanation:

If statement condition always returns true or false,which is a boolean data type.

X is true or false

it maybe a variable or an expression.

5 0
3 years ago
Read 2 more answers
Assume your organization has 200 computers. You could configure a tool to run every Saturday night. It would query each of the s
lukranit [14]

The tool that would provide a report listing all systems that are out of compliance, including specific issues is Security Compliance Manager.

<h3>What are compliance tools?</h3>

The Security Compliance Manager is known to be a form of downloadable tool that one can use as it helps a person to plan, ascribe, operate, and manage a person's security baselines for Windows client and other forms of server operating systems.

Note that in the case above, The tool that would provide a report listing all systems that are out of compliance, including specific issues is Security Compliance Manager.

Learn more about Security Compliance Manager from

brainly.com/question/24338783

#SPJ1

4 0
2 years ago
Code in Python
KIM [24]

You're setting the value of user_num to 20. Doing this won't allow the other test cases to run. Simply delete that line and your code should work. This is the code I wrote:

user_num = int(input())

while user_num>=1:

   user_num/=2

   print(user_num)

I wrote my code in python 3.8. I hope this helps.

4 0
2 years ago
Recent security innovations include all but the following _____. retina scanning password fingerprint scanning voice recognition
OlgaM077 [116]
Passwords have existed for centuries for passage through places as a means of security. 
5 0
3 years ago
Read 2 more answers
Other questions:
  • 2- There are many different design parameters that are important to a cache’s overall performance. Below are listed parameters f
    11·1 answer
  • Which are benefits of modeling a solution? Choose all that apply. allows you to be sure the problem and solution are understood
    9·2 answers
  • Which of the following statements is correct? A. The columns will be listed in the results in the same order they are stored in
    7·1 answer
  • Write a c++ program to calculate the approximate value of pi using this series. The program takes an input n that determines the
    13·1 answer
  • What connectionless protocols are implemented at the lower layers of the OSI model, what is usually used to acknowledge that the
    5·2 answers
  • For some reason, Danica's classmate George could not find the registered symbol in the symbol gallery. He is selling
    14·1 answer
  • MULTIPLE CHOICE QUESTION PLEASE HELP!!!!!!!!!
    14·2 answers
  • in java Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, o
    13·1 answer
  • What is a killer app??
    10·1 answer
  • What is your favorite LEGO set
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!