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

Write a program that will grade a set of Multiple Choice exams. The exam has 20

ID: 3668240 • Letter: W

Question

Write a program that will grade a set of Multiple Choice exams. The exam has 20 questions and there were 20 students in the class.

There will be two parts to the input. First, you must read the test answers from a file into a 2D array. Each row of the array will hold the answers given by one student - so the element at subscript 0 in the row of the array will hold the answer to the first question, the element at subscript 1 in the row will hold the answer to the second question, and so on.

The answers given by each student will be on a separate line in the input file, so there will be 20 answers on each line and there will be 20 lines.

The second part of the input is the answer key - the list of the correct test answers. The correct answers will be on one line. They should be read into a 1D array. (Note: The 21stline in the input file will contain the answer key.)

After reading in the test answers and the answer key, your program should grade each test by comparing each answer with the answer key and counting the number of correct answers. The number of correct answers for each test should be printed to an output file along with the corresponding grade for that test. Each correct answer is worth 5 points. The output file should be in report format.

You should also keep a running total of the sum of the student grades. At the end of the report list the average grade obtained on this exam by the 20 students.

You will use an input file to read the values into the array.

You will send the results to an output file.

You will use methods with parameters in your program.

Input data file:

1 C C D D A B C C B A B C D A D C C B D A

2 B D A A C A B A C D B C D A D C C B D A

3 B D D D C A B A C D B C D A D C C B D A

4 B C A A C A B A C D B C A A D C C B D A

5 B C A C C A C A C C B C D A D C C B D D

6 A D A A C A B D A D B A D A D C B B D C

7 B D A A C A B A C D B C D A D C C B D A

8 D D A A C A B A C D B C D A D C C B D A

9 B D D D A A A A C D B C D A B C C B D A

10 B D A A C A B A C D B C D A D C C B D A

11 B D A A C A B A C A B C D A D C C B D A

12 B D A D C A B A D D B C D A D C C B D A

13 B D A A C A B A B D B C D A D A A B D A

14 B D A A C A B A C D B C D A D C C B D A

15 B D A A C A B A C D B B C A C B B B D B

16 B D A A C A B A C D B C D A D C C B D A

17 B D A A C C C C C D B C D A D C C B D A

18 B D D A C A B A C D B C D A D B B B D A

19 B A D A C A B A B A B C D A D C C B D A

20 B D A A C A B A C D B C D A D C C B D A

21 B D A A C A B A C D B C D A D C C B D A

and the report output has to look like this

STUDENT EXAM RESULTS

Student Number # Correct Answers Grade

1 10 50

2 15 75

. . .

. . .

Explanation / Answer

input = open('input.txt','r')

user_response = {}

for line in input:

line = line.rstrip().split(' ',1)

user_response[intline[0]] = line[1].split(' ')

output = open('output.txt','w')

for i in range (1,21):

    count = 0

    for j in range(0,20):

         if user_response[i][j] == user_response[21][j]:

               count +=1

    output.write(str(i)+' '+str(count)+' '+str(count*5)+' ')

output,close()

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