Question: PYTHON DEBUGGING HELP: PLEASE FIX THIS PROBLEM 5: Let's define a subclass of Book called PaperBook. PaperBook should inherit from Book and should add an

PYTHON DEBUGGING HELP: PLEASE FIX THIS

PYTHON DEBUGGING HELP: PLEASE FIX THIS PROBLEM 5: Let's define a subclass

PROBLEM 5: Let's define a subclass of Book called PaperBook. PaperBook should inherit from Book and should add an instance variable called numTornPages, which is set to 0 in the constructor Add a method to the PaperBook class (NOT to the Book class) called ripPage , which increases numTornPages by 1 every time it is called In [43]: # define subclass here class PaperBook Book): def init_(self,title, author): self.numTornPages 0 super)._init(self) def ripPage (self): for x in self.numTornPages: self.numTornPages 1 In [44]: # manual test of subclass here last_lecture PaperBook ( 'The Last Lecture', 'Randy Pausch') print(last_lecture) Traceback (most recent call last) RecursionError in () 1 # manual test of subclass here 2 last-lecture PaperBook( 'The Last Lecture' , 'Randy Pausch') --3 print(last lecture) in -str-(self) 10 def str (self): - retur "%s by %s" % (self.title, self.author) 12 13 14 def getTitle(self) last 1 frames repeated, from the frame below ipython-input-1-65609b7b775f> in str (self) i 10 10 def str (self): . return " %s by %s" % (self, title, self.author) > 12 13 14 def getTitle(self): RecursionError: maximum recursion depth exceeded while getting the str of an object

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!