Question: Please solve problems one and two. Cheers Readings: This homework relies on following references: OOP Question 1: Person Modify the following Person class to add
Please solve problems one and two. Cheers

Readings: This homework relies on following references: OOP Question 1: Person Modify the following Person class to add a repeat method, which repeats the last thing said. If nothing has been said yet, you can have repeat return a string of your choosing. See the doctests for an example of its use. Hint: you will have to modify other methods as well, not just the repeat method. class Person (object) : nun >>> steven = Person ("Steven" ) >>> barb = Person ("Barb") >> steven. say ("Hello" ) 'Hello' >> steven. repeat ( ) Hello' >>> steven. greet( ) Hello, my name is Steven' >> barb. ask("listen to me repeat myself") 'Would you please listen to me repeat myself' >> barb. repeat( ) IWould you plance licton to mo ropost mycolfl >> steven. repeat ( ) 'Hello, my name is Steven' def init_(self, name) : self : name = name "*** YOUR CODE HERE **" return stuff def ask(self, stuff) : return self. say("Would you please " + stuff) def greet(self) : return self. say ("Hello, my name is " + self. name) def repeat (self) : "*** YOUR CODE HERE ***" Use OK to test your code: python3 ok -q Person Question 2: Account There are several things wrong with the following code! Debug the Account class to satisfy the docstring. class Account (object) : ""A bank account that allows deposits and withdrawals. >>> sophia_account = Account ( ' Sophia' ) >>> sophia_account . deposit(1000000) # depositing my paycheck for the week 1000000 >>> sophia_account . transactions [ ( ' deposit', 1000000) ] >> sophia_account. withdraw(100) # buying dinner 999900 >>> sophia_account . transactions [ ( 'deposit', 1000000), ('withdraw', 100) ] interest = 0.02 balance = 1000 def _init_(self, account_holder) : self. balance = 0 self. holder = account_holder self. transactions = def deposit (self, amount) : ""Increase the account balance by amount and return the new balance. self. transactions . append ( ( ' deposit', amount) ) Account . balance = self . balance + amount return self. balance def withdraw(self, amount) : ""Decrease the account balance by amount and return the new balance. self . transactions . append ( ( 'withdraw' , amount) ) if amount > self. balance: return 'Insufficient funds self. balance = Account. balance - amount return Account . balance Use OK to test your code: python3 ok -q Account
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
