Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 2 Classes with highest plagiarism ratio Plagiarism has become a big issu

ID: 3589061 • Letter: P

Question

Problem 2 Classes with highest plagiarism ratio Plagiarism has become a big issue in programming classes these days as people have started to value grades more than the actual learning. Here we have stats from a few programming classes and we would like to know which class has the highest plagiarism. We are given stats in the form of a string like "490:404-30- 28". Explanation : 490 is the class number, 404 is the number of students in the class, 30 students were accused of plagiarism and 28 were found guilty. The class with the highest plagiarism is determined by the ratio which in this case is 28/404 You will give be given a list of such strings which represents the class and respective stats. You have to break the string down into groups and extract these stats and convert them into an integer. Once you have done that you will create a dictionary in which every class number corresponds to the ratio of number of students found guilty to number of students in the class In stats r'490:404-30-28, '225:300-99-98, '391:410-54-45', '544;120-15-10' In 1: def highest plagiarism ratio(stats) Find tho class with tho highost plagiarism ratio Parameters stats : A list of strings where each string is the class number and stats of the class Returns A string max-plagiarism class = None # YOUR CODE HERE return max_plagiarism_class In 1: assert equal (Lype (highest plagiarism ratio (stals)), str) assert_equal (highest_plagiarism ratio(stats), "225') assert_equal (highest_plagiarism_rat.io (I'225300-99-9',241:200-94-93,'374:320-14-11'1),241)

Explanation / Answer

stats = ['490;404-30-28', '225;300-99-98', '391;410-54-45', '544;120-15-10']

def highest_plagiarism_ratio(stats):
plag_dict = {}
max_plagiarism_ratio = -1
max_plagiarism_class = None
for s in stats:
(classNo, classStats) = s.split(";")
(strength, accused, guilty) = classStats.split("-")
ratio = float(guilty)/int(strength)
plag_dict[classNo] = ratio
if ratio > max_plagiarism_ratio:
max_plagiarism_ratio = ratio
max_plagiarism_class = classNo
return max_plagiarism_class

assert_equal(type(highest_plagiarism_ratio(stats)), str)
assert_equal(highest_plagiarism_ratio(stats), '225')
assert_equal(highest_plagiarism_ratio(['225;300-99-98', '241;200-99-98', '374;320-14-11']),'241')

# code link: https://paste.ee/p/2cIVR

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote