Menu

[Solved]-Python Create Instance Testquestion Class Main Method Allow User Enter Test Question Answe Q37270292

IN PYTHON ONLY !!

Create an instance of the “TestQuestion” class in your “main”method. Allow the user to enter the test question and its answer,if they want to. If they do not, then continue by creating adefault question and answer. Please use the constructor methodshere. Then, using the “ToString” or “__str__” method, have it printout those variables as described above.

Lastly, call the “CheckAnswer” method and allow the user tocontinue attempting to answer the question until they are correct.If they are correct, the method should work as above and allow themto enter a new question and answer. You may either terminate theprogram at this point (if the user types “quit”) or allow for aninfinite series of trivia games.

Example:

Please enter a test question (or just hit enter to skip): “Whatis your favorite color?”

Please enter the answer to that question (or just hit enter toskip): “Blue”

Your question was: “What is your favorite color?” and youranswer was: “Blue”

Please enter your answer to the test question: “Red”

I’m sorry, you were incorrect and have not dethroned theprevious champion. Please enter another answer to the testquestion: “Blue”

You are the new champion. Claim your prize by setting a new moredifficult question: “What is the airspeed velocity of an unladenSwallow?”

And the answer to that question: “24 miles per hour.”

Your question was: “What is the airspeed velocity of an unladenSwallow?” and your answer was: “24 miles per hour.”

…. (It should continue asking for the correct answer. Otherwiseit should end here if the user types “quit”.)

Example using Default Question and Answer:

Please enter a test question (or just hit enter to skip): “”

Please enter the answer to that question (or just hit enter toskip): “”

Your question was: “Find the value of x in 4 = x ^ 2” and youranswer was: “2”

Please enter your answer to the test question: “16”

I’m sorry, you were incorrect and have not dethroned theprevious champion. Please enter another answer to the testquestion: “4”

You are the new champion. Claim your prize by setting a new moredifficult question: “What is the airspeed velocity of an unladenSwallow?”

Please enter the answer to that question: “24 miles perhour.”

Your question was: “What is the airspeed velocity of an unladenSwallow?” and your answer was: “24 miles per hour.”

…. (It should continue on like that, if using a loop. Otherwiseit should end here.)

Expert Answer


Answer to IN PYTHON ONLY !! Create an instance of the “TestQuestion” class in your “main” method. Allow the user to enter … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *