Please code in python and please put all code in functions. Thank you. Goal: fun
ID: 3730170 • Letter: P
Question
Please code in python and please put all code in functions. Thank you.
Goal: functions with lists and tuples You are to create a program that will aid in grading a multiple choice assessment that contains 20 questions. Your program will compare the answers from a student to the correct answers and determine if the student answered at least 75% of the questions correctly to pass the assessment. Your program will also provide an output listing the correct answers, the student's answers, and whether the student's answers were correct. The answers will be upper case letters A through E and you may assume the student answered all 20 questions. Your program should employ 3 functions other than main (which will act as a driver for the other functions). The first of these 3 functions should be used to input the student's answers This function should not accept any parameters and will return a list containing upper case characters for the student's answers. Inside this function use a loop to prompt the user to enter the student's responses to the 20 questions one at a time and stored the student's responses in a list. You may assume that the user will input an appropriate upper case character for the student's response. Once the loop is finished, the list of student's responses should be returned to the function call. The second of these functions will compare the student's answers to the correct answers and count how many answers are correct. This function should accept 2 parameters (a tuple of correct answers and the list of student's answers), and will return the string "Passed" when the student answers at least 15 questions correctly. When the student answers fewer than 15 questions correctly, the string "Failed" should be returned. A loop should be used to count the number of questions the student answered correctly and should be returned to the function call along with the string. Note two items are being returned to the function call: the string indicating that the student passed or failed and the number of questions the student answered correctly. The third function will output the correct answers, the student's answers and whether the student's answers were correct in table. This function should accept two parameters (the tuple of correct answers and the list of student's answers) and will not return anything to the function call. Using a loop the function should output the question number, the correct answer, the student's answer, and either the string "correct" or "incorrect". (See below for an example) Sample output: Question 1: Expected Answer: B Student's Answer: C Incorrect Question 2: Expected Answer: D Student's Answer: D Correct Question 3: Expected Answer: A Student's Answer: A CorrectExplanation / Answer
def InputAnswer(): ans = [] for i in range(1, 21): m = input('Enter answer to question: {:d}: '.format(i)) ans.append(m) return ans def compare(right, ans): check = 0 for i in range(0, 20): if right[i] == ans[i]: check += 1 if check > 14: return 'passed', check else: return 'failed', check def output(right, ans): for i in range(0, 20): if right[i] == ans[i]: ch = 'Correct' else: ch = 'Incorrect' print('Question {:d}: Expected Answer: {:s} Student''s Answer: {:s} {:s}'.format(i+1, right[i], ans[i], ch)) def main(): correct = ('A', 'B', 'C', 'D', 'E', "B", "E", 'A', 'C', 'B', 'A', 'B', 'C', 'D', 'E', "B", "E", 'A', 'C', 'B') ans = InputAnswer() status, num = compare(correct, ans) print('The student', status) print('The student answered', num, 'questions correctly') print('Would you like to see a detailed report of the correct answers and the student’s responses(y/n)?') n = input() if n.lower() == 'y': output(correct, ans) if __name__ == '__main__': main()