Put ALL your code for this question in a single module \"gradingXXXXX.py\" where
ID: 638054 • Letter: P
Question
Put ALL your code for this question in a single module "gradingXXXXX.py" where XXXXX
is your student ID
An exam has 20 multiple-choice questions (A,B,C,D). A student answer is stored in a
file with each line containing a letter. The correct answers are defined by this list:
solution = ['A', 'C', 'A', 'A', 'D',
'B', 'C', 'A', 'C', 'B',
'A', 'D', 'C', 'A', 'D',
'C', 'B', 'B', 'D', 'A']
Student passes the exam if 15 or more answers are correct.
Print out the message
Write the code to ask user to enter a file name containing the student answers.
The code prints "Congratulations!! You passed the exam." or
"Sorry, you did not pass the exam."
Print the number of correct answers, incorrect answers, and the list of incorrect answers.
Your are given 3 test files to test your code individually:
-answer1_20.txt
-answer2_18.txt
-answer3_12.txt
If user enter a file that does not exist, print an error messag?
>>>
Enter student answer file: answer1_20.txt
Congratulations!! You passed the exam.
Number of questions you answered correctly: 20
Number of questions you answered incorrectly: 0
>>> ================================ RESTART ================================
>>>
Enter student answer file: answer2_18.txt
Congratulations!! You passed the exam.
Number of questions you answered correctly: 18
Number of questions you answered incorrectly: 2
Questions you answered incorrectly:14, 18
>>> ================================ RESTART ================================
>>>
Enter student answer file: answer3_12
The file could not be found
>>> ================================ RESTART ================================
>>>
Enter student answer file: answer3_12.txt
Sorry, you did not pass the exam.
Number of questions you answered correctly: 12
Number of questions you answered incorrectly: 8
Questions you answered incorrectly:1, 2, 6, 7, 9, 14, 18, 20
Explanation / Answer
if letter===answer[0]:
count++
end
here finally print pass or fail by means of count
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.