Question: [Using Python] Create a program to generate one random question, from a list of 5, for each repeated run. Report the number of the correct

[Using Python] Create a program to generate one random question, from a list of 5, for each repeated run. Report the number of the correct answers after all five questions have been answered.

Your 5 questions should be a simple math problem, like "what is 5-4?"

  • use a while loop based on the number of questions
    • use a counter variable to count the number of questions asked
    • e.g. questionCount +=1
  • user a counter variable to keep track of the correct answers
    • e.g. correctCount +=1
  • for the questions, generate random numbers between 0 and 9
    • e.g. random_number = random.randint(0, 9
    • you will need "import random" as the first line in your program
  • all questions should be larger number - smaller number
    • i.e. so if the first generated number is 1 and the second 2
    • your question should be 2-1 (not 1-2)

Example:

display "What is 8-2?"

input answer is 2

display "Your answer is incorrect"

display "What is 10-4?"

input answer is 6

display "Your answer is correct"

display "What is 9-4?"

input answer is 4

display "Your answer is correct"

display "What is 2-1?"

input answer is 1

display "Your answer is correct"

display "What is 2-1?"

input answer is 2

display "Your answer is incorrect"

display ""Correct count is 3 out of 5"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!