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.

Expert's answer

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!

LATEST TUTORIALS
APPROVED BY CLIENTS