Question: Python coding O Question 3 (4 points): Define a function called quiz 3 that takes two inputs, both of which will be the name of

Python coding

Python coding O Question 3 (4 points): Define a function called quiz

O Question 3 (4 points): Define a function called quiz 3 that takes two inputs, both of which will be the name of a different .txt file. You can assume that each file contains a single line of text. Your function should compute how similar the two files are by going through each file character by character (including spaces and punctuation, etc.) and finding the percentage of characters that are exactly the same in the exact same place. In other words, check the first character in each to see if they are the same, and if they are, that counts as two matches; then it will check the second character of each file, and if they are the same, that counts as another two matches, etc. Once it is finished checking all characters, you will divide the number of matches (which should be an even number since each match counts as two) by the total number of characters combined between the two files, and finally convert that quotient to a percentage. Your function should then print this percentage. As an example, if ex1.txt' contains This is a single line of text. and if ex2.txt' contains This is another line of text. then the grader should be able to run your code and type quiz_3('ex1.txt', 'ex2.txt') and python should print 30.508474576271187 % (the result of 18 matches out of 59 total characters between the two files)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!