Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[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

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

Students also viewed these Databases questions

Question

How well did your team handle differences of opinion?

Answered: 1 week ago