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

In Python, A local college has asked you to create a Python program which will g

ID: 3819683 • Letter: I

Question

In Python, A local college has asked you to create a Python program which will grade a certain portion of the final. The final has 25 questions where the answer is either, A,B,C or D. Here are the correct answers:

A

D

C

B

A

A

D

C

B

A

A

D

C

B

A

A

D

C

B

A

C

D

D

D

D

You program will need to store these correct answers in a list. Also, your program should read from a text file called ‘student_answers.txt’ the student’s answers for each of the 5 questions and place the student’s answers in another list. After grading the final the program needs to display, the percentage correct and a letter grade which can be found in the grading scale below. It should then display the total number of correct answered questions, the total number of incorrectly answered questions and a list showing the question number of the incorrectly answered questions.

Finalple Output

Percentage Correct

88%

Letter Grade

B

You incorrectly answered

3 questions

You correctly answered

22 questions

You missed question numbers

1,5,12

Grading Scale

Test Score

Grade

>=90% and above

A

>=80% and <90%

B

>=70% and <80%

C

>=60% and <70%

D

<60% and below

F

The program should contain at least 3 functions, one for input (which should be called main), one for processing and one for output. The data will need to pass from main into your processing function and from the processing function to the output function.

Here is what I have:

def main():
    correct_answers = ['A','D','C','B','A','A','D','C','B','A','A','D','C','B','A','A','D','C','B','A','C','D','D','D','D']
    student_answers = []
with open("student_answers.txt","r") as ins:
    for line in ins:
        student_answers.append(line.rstrip(' '))
        processing(correct_answers,student_answers)
def processing(correct_answers,student_answers):
    correct = 0
    wrong = 0
    missed = []
    for i in range(len(correct_answers)):
        if(correct_answers[i]==student_answers[i]):
            correct +=1
        elif(student_answers[i]==""):
                missed.append(i+1)
        else:
             wrong +=1
             percentage = (correct/len(correct_answers))*100
             output(correct,wrong,missed,percentage)
def output(correct,wrong,missed,percentage):
    print("persentage correct %d%%" %(percentage))
    if(percentage>=90):
        print("Letter Grade A")
    elif(percentage < 90 and percentage >= 80):
        print("Letter Grade B")
    elif(percentage < 80 and percentage >= 70):
        print("Letter Grade C")
    elif(percentage < 70 and percentage >= 60):
        print("Letter Grade D")
    else:
        print("Letter Grade F")
    print("You incorrectly answered %d questions" %(wrong))
    print("You correctly answered %d questions" %(correct))
    if len(missed) == 0:
        print("you missed question numbers 0")
    else:
        print("you missed question numbers " + (",".join(map(str,missed))))
    if __name__ == '__main':
        main()


and I am getting this error:

Traceback (most recent call last):
File "C:UsersOrnaDesktopShearin_FinalProject.py", line 6, in <module>
    student_answers.append(line.rstrip(' '))
NameError: name 'student_answers' is not defined

Can anyone help me figure what I have done wrong?

Finalple Output

Percentage Correct

88%

Letter Grade

B

You incorrectly answered

3 questions

You correctly answered

22 questions

You missed question numbers

1,5,12

Explanation / Answer

def main():
    correct_answers = ['A','D','C','B','A','A','D','C','B','A','A','D','C','B','A','A','D','C','B','A','C','D','D','D','D']
    student_answers = []
with open("student_answers.txt","r") as ins:
    for line in ins:
        student_answers.append(line.rstrip(' '))
        processing(correct_answers,student_answers)
def processing(correct_answers,student_answers):
    correct = 0
    wrong = 0
    missed = []
    for i in range(len(correct_answers)):
        if(correct_answers[i]==student_answers[i]):
            correct +=1
        elif(student_answers[i]==""):
                missed.append(i+1)
        else:
             wrong +=1
             percentage = (correct/len(correct_answers))*100
             output(correct,wrong,missed,percentage)
def output(correct,wrong,missed,percentage):
    print("persentage correct %d%%" %(percentage))
    if(percentage>=90):
        print("Letter Grade A")
    elif(percentage < 90 and percentage >= 80):
        print("Letter Grade B")
    elif(percentage < 80 and percentage >= 70):
        print("Letter Grade C")
    elif(percentage < 70 and percentage >= 60):
        print("Letter Grade D")
    else:
        print("Letter Grade F")
    print("You incorrectly answered %d questions" %(wrong))
    print("You correctly answered %d questions" %(correct))
    if len(missed) == 0:
        print("you missed question numbers 0")
    else:
        print("you missed question numbers " + (",".join(map(str,missed))))
    if __name__ == '__main':
        main()

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