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

How to write a program using Python programming language that will grade a porti

ID: 3824765 • Letter: H

Question

How to write a program using Python programming language that will grade a portion of a final test and store the answers in a list. The program should read from a text file called 'student_answers.txt' the student's answers for the 25 questions and place the student's answer in another list. After grading the exam the program needs to display, the percentage correct, and a letter grade(scale listed below). It should then display the total number of correctly answered question's, the total number of incorrectly answered questions, and a list showing the question numbers that were answered incorrectly.

Test Score   Grade

>=90 and above A

>=80 to 90 B

>=70 to 80 C

>=60 to 70 D

<60 and below F

An example of output:

Percentage correct.........88%

Letter grade.....B

You incorrectly answered.......3

You correctly answered.......22

You missed questions.........1,5,12

Explanation / Answer

Here is the similar code, but for 20 questions:

#! /usr/bin/python
#The program should store these correct answers in a list.
CorrectAnswers = [ 'A' ,'C' , 'A', 'A', 'D', 'B', 'C', 'A', 'C', 'B', 'A', 'D', 'C', 'A', 'D', 'C', 'B', 'B', 'D', 'A' ]
#The program should read the student's answers for each of the 20 questions from a text file and store it in another list.
userInput = open("UserAnswers.txt", "r")
UserAnswers = [None] * 20
for i in range(20):
UserAnswers[i] = userInput.read(1)
newLine = userInput.read(1)
#After the students answer's have ben read from the file, the program should display a
#message indicating whether the student passed or failed the exam.
#(A student must answer 15 out of 20 correctly to pass.)
correctAnswersCount = 0
for i in range(20):
if CorrectAnswers[i] == UserAnswers[i]:
correctAnswersCount += 1
if correctAnswersCount < 15:
print 'Oops you failed the test.'
else:
print 'Congratulations. You passed the test.'
#The program should then display the the total number of correct and incorrect questions,
#and a list showing the question numbers of the inoccerect questions
print 'The number of correct answers by you: ', correctAnswersCount
print 'The number of wrong answers by you: ', 20 - correctAnswersCount
for i in range(20):
print (i+1), 'Your answer: ', UserAnswers[i],
if UserAnswers[i] == CorrectAnswers[i]:
print 'Correct'
else:
print 'Wrong. Correct Answer is: ', CorrectAnswers[i]

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