Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following implementation of the Person class: class Person: ' ' ' > > > john = Person ( John ) >
Consider the following implementation of the Person class:
class Person:
john PersonJohn
john.repeat
'Initialize any value'
john.sayHello
'Hello'
john.repeat
'Hello'
john.greet
'Hello, my name is John'
john.repeat
'Hello, my name is John'
john.askpick up the trash'
'Would you please pick up the trash?
john.repeat
'Would you please pick up the trash?
def initself name:
self.name name
def sayself phrase:
return phrase
def askself phrase:
return self.sayfWould you please phrase
def greetself:
return self.sayfHello my name is selfname
The Person class needs to be modified to add the method repeat which repeats the last thing said. Examples of its functionality are shown in the doctest. Select the line that must be added to the current implementation to so instances of the class behave as shown in the doctest. If no changes are required for a method, select No changes needed"
Group of answer choices
def initself name:
Choose
def sayself phrase:
Choose
def askself phrase:
Choose
def greetself:
Choose
def repeatself:
Choose self.last self.say return self.lastself.last return self.sayfHellomy name is selfname No changes needed None self.last "initialize any value" return self.sayselflast return last self,last phrase return "initialize any value" self. last None
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started