Answered step by step
Verified Expert Solution
Link Copied!

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 = Person("John")
>>> john.repeat()
'Initialize any value'
>>> john.say('Hello')
'Hello'
>>> john.repeat()
'Hello'
>>> john.greet()
'Hello, my name is John'
>>> john.repeat()
'Hello, my name is John'
>>> john.ask('pick up the trash')
'Would you please pick up the trash?'
>>> john.repeat()
'Would you please pick up the trash?'
'''
def __init__(self, name):
self.name = name
def say(self, phrase):
return phrase
def ask(self, phrase):
return self.say(f"Would you please {phrase}?")
def greet(self):
return self.say(f"Hello, my name is {self.name}")
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 __init__(self, name):
[ Choose ]
def say(self, phrase):
[ Choose ]
def ask(self, phrase):
[ Choose ]
def greet(self):
[ Choose ]
def repeat(self):
[ Choose ] self.last = self.say/ return self.last+self.last/ return self.say(f"Hello,my name is {self.name}")/ No changes needed/ None/ self.last = "initialize any value"/ return self.say(self.last)/ 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions