Answer to Question #307858 in Python for Ratul

Question #307858



Midterm Questions-checkpoint.ipynb


Midterm Questions-checkpoint.ipynb_


𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 1


As you are a student of university now, you need to ensure your assignments


are plagiarism-free. To do this, you decide to design a simple plagiarism


checker. Your checker will take 2 strings as input. Then it will compare


the 2 strings and check how many words they have in common. Then, print the


percentage in common, by calculating:



(No. of words in common / (No of words in string 1 + No of words in string 2)) * 100.



If the calculated plagiarism is greater than or equal to 30%,


print “Plagiarism detected.” Otherwise, print “Good job!”.



Note: you need to compare “words” not individual characters. You can


consider that all characters in both inputs will be in only lowercase or


uppercase.

1
Expert's answer
2022-03-08T16:03:33-0500
def plag_checker(input1, input2):
    input1 = input1.lower()
    input2 = input2.lower()
    j = 0
    for i in set(input1.split(' ')):
        if i in set(input2.split(' ')):
            j = j + 1
    if j / (len(set(input1.split(' '))) + len(set(input2.split(' ')))) >= 0.3:
        return 'Plagiarism detected'
    else:
        return 'good job'



plag_checker('what do we have in common', 'we do not have anything in common' )

'Plagiarism detected'

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS