A Tiny Plagiarism Checker
Intermediate · Write the code · from Legal and Ethical Concerns: Copyright, Plagiarism and Open Licenses
From the lesson: Legal and Ethical Concerns: Copyright, Plagiarism and Open Licenses
Anything you make on a computer, from a song to a game level, belongs to someone, and computers make it possible to copy that work in seconds.
Read the lessonWrite word_overlap(text_a, text_b) that measures how much two texts share. Lowercase each text, split it into words, and strip the characters .,!? from both ends of each word. Collect each text's words in a set. Return the number of words in both sets divided by the number of words in either set, as a percent rounded to 1 decimal place. If neither text has any words, return 0.0.
word_overlap("the cat sat on the mat", "the cat sat on a mat") -> 83.3def word_overlap(text_a, text_b):
# Turn each text into a set of cleaned-up words, then compare
pass
What Check runs
Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.
| Runs | Expected output |
|---|---|
| print(word_overlap("the cat sat on the mat", "the cat sat on a mat")) | 83.3 |
| print(word_overlap("Python is fun.", "python IS fun!")) | 100.0 |
| print(word_overlap("red green", "blue yellow")) | 0.0 |
More Computing Ethics exercises
- Write an AttributionBeginner
- Does the License Allow It?Intermediate