Question: Question 4: Write a Python code to implement a Quiz using lists. (10 points) Your program displays 5 questions selected in random order from a
Question 4: Write a Python code to implement a Quiz using lists. (10 points) Your program displays 5 questions selected in random order from a question bank that consists of 6 questions. Then your program inputs the user's answers and computes and prints her/his score. The table below shows the questions and their corresponding correct answers: Q1. 4+1=7 Correct answerr Complete the following program by implementing the requirements Q2: 5//41 Correnct ansterer cortrect, answer requested in the comments from (1) to (7). Q4: A AXS-0 \#(1) import the required standard library function (1pt) Q9. 1 WM/A 25 Correct unswer Voser scere =4 \#(2) Create the lists questions and answers as shown in the table (3.5pt) questions = answers = score - e \#counts correct user answers \#(3) Create an empty 1ist selectedpositions to store the random indexes of the questions to be selected and displayed to the user (0.5pt) selectedpositions = for 1 in range (5): \#(4) Generate a randon index pos in the range to 5 that is not already "selected (2pt) while H(5) Add pos to the list setectedpositions (1pt) F(6) Pronpt the user with the question's number and text, using variable \#pos to access the selected question and read user answer (1pt) useranswer-int (input ("Qxd: x : " C )) *(7) Check if user answer is correct (1pt) if score - score + 1 print('Correct answer') se: print('Wrong answer'') your score - ', score) else: print('Your score - ', score)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
