Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions