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

Textbook: Starting out with Python 3rd edition by Tony Gaddis Chapter 7, program

ID: 3689525 • Letter: T

Question

Textbook: Starting out with Python 3rd edition by Tony Gaddis

Chapter 7, programming exercise 7.Drivers license exam

The local drivers license office has asked you to create an application that grades the written portion of the drivers license exam. the exam has 20 mult. choice questions. here are the correct answers

correct_answers = ['A','C','A','A','D','B','C','A','C','B','A','D','C','A','D','C','B','B','D','A']

Your program should store these correct answers in a list. The program should read the students answers for each of the 20 questions from a text file (student_solution.txt) and store the answers in another list. After the students answers have been read from the file, the program should display a message indicating whether the student passed or failed the exam (a 15/20 is required to pass). It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered question.

please post answer in python 3

Explanation / Answer

f = open("student_solution.txt")
ansg = []
ansr = ['A','C','A','A','D','B','C','A','C','B','A','D','C','A','D','C','B','B','D','A']
inc = []
while True:
c = f.read(1)
if not c:
break
if(c>='A' and c<'Z'):
ansg.append(c)
cans = 0
for i in range(20):
if(ansg[i]==ansr[i]):
cans+=1
else:
inc.append(i+1)
if(cans>=15):
print("The student passed the exam")
else:
print("The student failed the exam")
print("The number of correctly answered questions is",cans)
print("The number of incorrectly answered questions is",20 - cans)
print("The list of incorrectly answered questions is",inc)

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