Question

In: Computer Science

You are a college professor who suspects that students have copied each others answers on a...

You are a college professor who suspects that students have copied

each others answers on a multiple choice (a,b,c,d) exam.

Building on the code I have developed  CheatingCodeForCompletion.py , you are to

develop a program that will tell you which students have identical answers.

I have developed the code that will generate answers for each of the students.

You are to complete the code to analyze the answers and print to the screen

your analysis as demonstrated in the two example below

(please note that the output of the names of those who copied prints the names twice).  

CheatingCodeForCompletion.py, (below and loaded to eLearn)

import random

##the students in the class

##the most popular names in 2020

["Oliver",\

"Liam",\

"Ethan",\

"Aiden",\

"Gabriel",\

"Caleb",\

"Theodore",\

"Declan",\

"Owen",\

"Elijah",\

"Charlotte",\

"Ava",\

"Amelia",\

"Olivia",\

"Aurora",\

"Violet",\

"Luna",\

"Hazel",\

"Cloe",\

"Aria"

]

##needed to build the test results

test_results = []

answers = ['a', 'b', 'c', 'd']

num_questions = 3  ##Smaller number yields more instances of cheating

##this code will build a dictionary of length 20 of

##key - student name

##value - a list of num_questions length of randomly selected

##values from the list answers above

for student in students:

  result = []

  for i in range(num_questions):

  result.append(random.choice(answers))

  test = {}

  test[student] = result

  test_results.append(test)

Done in Python format Please

Solutions

Expert Solution

Here is the code:

import random
##the students in the class
##the most popular names in 2020
students = ["Oliver","Liam","Ethan","Aiden","Gabriel","Caleb","Theodore","Declan","Owen","Elijah","Charlotte","Ava","Amelia","Olivia","Aurora","Violet","Luna","Hazel","Cloe","Aria"]
len(students)


##needed to build the test results
test_results = []
answers = ['a', 'b', 'c', 'd']
num_questions = 3  ##Smaller number yields more instances of cheating

##this code will build a dictionary of length 20 of
##key - student name
##value - a list of num_questions length of randomly selected
##values from the list answers above
for student in students:
    result = []
    for i in range(num_questions):
        result.append(random.choice(answers))
        test = {}
        test[student] = result
    test_results.append(test)
test_results


indices = list()
for loop1 in range(len(test_results)):
    for loop2 in range(loop1+1,len(test_results)):
        if(loop1 != loop2):     # if both the index are not same
            if(test_results[loop1][students[loop1]] == test_results[loop2][students[loop2]]):
                indices.append((loop1,loop2))
indices

# printing names of students who cheated
for item in indices:
    print(students[item[0]],students[item[1]])

Here is the results:

If you have any doubt, please comment below.


Related Solutions

A professor states that in the United States the proportion of college students who own iPhones...
A professor states that in the United States the proportion of college students who own iPhones is .66. She then splits the class into two groups: Group 1 with students whose last name begins with A-K and Group 2 with students whose last name begins with L-Z. She then asks each group to count how many in that group own iPhones and to calculate the group proportion of iPhone ownership. For Group 1 the proportion is p1 and for Group...
A professor states that in the United States the proportion of college students who own iPhones...
A professor states that in the United States the proportion of college students who own iPhones is .66. She then splits the class into two groups: Group 1 with students whose last name begins with A-K and Group 2 with students whose last name begins with L-Z. She then asks each group to count how many in that group own iPhones and to calculate the group proportion of iPhone ownership. For Group 1 the proportion is p1 and for Group...
A professor states that in the United States the proportion of college students who own iPhones...
A professor states that in the United States the proportion of college students who own iPhones is .66. She then splits the class into two groups: Group 1 with students whose last name begins with A-K and Group 2 with students whose last name begins with L-Z. She then asks each group to count how many in that group own iPhones and to calculate the group proportion of iPhone ownership. For Group 1 the proportion is p1 and for Group...
A professor states that in the United States the proportion of college students who own iPhones...
A professor states that in the United States the proportion of college students who own iPhones is .66. She then splits the class into two groups: Group 1 with students whose last name begins with A-K and Group 2 with students whose last name begins with L-Z. She then asks each group to count how many in that group own iPhones and to calculate the group proportion of iPhone ownership. For Group 1 the proportion is p1 and for Group...
A professor wishes to estimate the proportion of college students that have never cheated during a...
A professor wishes to estimate the proportion of college students that have never cheated during a course. She wishes to estimate the proportion to be within​ 4.15% with​ 96% confidence. How many teenagers are needed for the​ sample? A. 613 B. 611                           C. 612 D. 614 E. Insufficient information to answer the question
A professor believes that students who have the opportunity to write their essays on word processors...
A professor believes that students who have the opportunity to write their essays on word processors will produce better essays than those who write them by hand. Design an experiment that tests this idea. 1. Do you need to define any terms for your experiment (operationally define)? If so, define them here. 2. What purpose would this line of research serve (and which subgroup do you think this experiment would most closely relate with)?
A college professor wants to select three students among twelve students to clean the room. The...
A college professor wants to select three students among twelve students to clean the room. The first student selected will clean the windows, the second student selected will do all the other work, while the third student selected will supervise all activities. In how many different ways can the professor select 3 students form this group.
1. A researcher is interested in whether college students get enough sleep. She suspects that they...
1. A researcher is interested in whether college students get enough sleep. She suspects that they get less than 8 hours of sleep on average. The sample mean (x¯) for 65 students was 7.08 hours. The standard deviation of number of hours students slept is s=1.8. (a) Determine the null and alternative hypothesis for the test. What is the parameter in this study? (b) The p-value for the test is <0.0001. Using a significance level of .05, write a one...
A researcher is interested in whether college students get enough sleep. She suspects that they get...
A researcher is interested in whether college students get enough sleep. She suspects that they get less than 8 hours of sleep on average. The sample mean (x ̄) for 65 students was 7.08 hours. The standard deviation of number of hours students slept is s=1.8. (a) Determine the null and alternative hypothesis for the test. What is the parameter in this study? (b) The p-value for the test is <0.0001. Using a significance level of .05, write a one...
10% of all college students volunteer their time. Is the percentage of college students who are...
10% of all college students volunteer their time. Is the percentage of college students who are volunteers smaller for students receiving financial aid? Of the 339 randomly selected students who receive financial aid, 17 of them volunteered their time. What can be concluded at the αα = 0.01 level of significance? For this study, we should use Select an answer t-test for a population mean z-test for a population proportion The null and alternative hypotheses would be:    H0:H0:  ? p...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT