Question: Python: A class Question is designed to models xam questions. Please implement the class with the following functions: def __init__ (self) : #constructs a question

Python: A class Question is designed to models xam questions. Please implement the class with the following functions:

def __init__ (self) : #constructs a question with empty question and answer strings.

def setText (self, questionText) : #set the question text

def setAnswser(self, correctResponse) : #set answer for this question

def checkAnswer(self, response) : #check if a given answer is correct or not

def display(self) : display the question

Also, a ChoiceQuestion class inherits from the Question class, that could handle multiple choices like the following:

In which country the inventor of Python born?

Australia 2. Canada 3. Netherlands 4. United States

The subclass has its own constructor (self._choice = []), a new method addChoice (self, choice, correct) will be added. For example,

question.addChoice(Canada, False)

question.addChoice(Netherlands, True)

#in this case, you will set answer to 3 by calling the base function setAnswer(3).

It also overrides the display function.

Testing: Play with the above using questions such as:

Question: What is Python Answer: A programming language User response: various

The above choice question

Add a number of your testings.

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!