Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4. Add a subclass FillInQuestion to the question hierarchy of Section 10.1. Such

ID: 3717433 • Letter: 4

Question

4.      Add a subclass FillInQuestion to the question hierarchy of Section 10.1. Such a question is constructed with a string that contains the answer, surrounded by _ _, for example, “the inventor of Python was _Guido van Rossum_”. The question should be displayed as 6 pts

The inventor of Python was _______

Below is the program that runs the modified class Question:

##

# Demonstrate the FillInQuestion class.

#

# Create the question and expected answer.

q = FillInQuestion()

q.setText("The inventor of Python was _Guido van Rossum_")

# Display the question and obtain user's response.

q.display()

response = input("Your answer: ")

print(q.checkAnswer(response))

a)     Your code with comments

b)     A screenshot of the execution

section10.1:

1. Identify the superclass and subclass in each of the following pairs of classes.

a) Employee, Manager

b) Student, GraduateStudent

c) Employee, Professor

d) Truck, Vehicle

use python to programe this Q and please make sure to include the commenst in the coding and make sure do not copy and past here i saw all the answers here in chegg but not what i want, and show me screenshot of the output

Explanation / Answer

class Question: def __init__(self): self.text = "" self.answer = "" def setText(self,text): self.text = text def setAnswer(self,answer): self.answer = answer def display(self): print(self.text) def checkAnswer(self,response): ans = self.answer.replace(' ','') ans = ans.lower() response = response.replace(' ','') response = response.lower() if(response == ans): return "Correct answer" else: return "Wrong answer" class FillInQuestion (Question): def __init__(self): super(Question, self).__init__() def setText(self,text): temp = text.split("_") temp[0] = temp[0] + "_______" super(FillInQuestion,self).setText(temp[0]) super(FillInQuestion, self).setAnswer(temp[1]) def main(): # Create the question and expected answer. q = FillInQuestion() q.setText("The inventor of Python was _Guido van Rossum_") # Display the question and obtain user's response. q.display() response = input("Your answer: ") print(q.checkAnswer(response)) main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote