Question: Pleae write the answer in Python 3 EXAMPLE CODE TO MODIFY class BankAccount: Simple BankAccount class def __init__(self, balance=0): Initialize account with balance

Pleae write the answer in Python 3
EXAMPLE CODE TO MODIFY
class BankAccount: """ Simple BankAccount class """
def __init__(self, balance=0): """Initialize account with balance""" self.balance = balance
def deposit(self, amount): """Deposit amount to this account""" self.balance += amount
def withdraw(self, amount): """Withdraw amount from this account""" self.balance -= amount
(a). (6 pts) Implement __str__ and __repr__ as shown below.
(b). (10 pts) Implement truthiness for our BankAccount objects, such that an instance is truthy if the balance is greater than zero and falsey if the balance is less than or equal to zero.

(c). (14 pts) Implement comparisons for our BankAccount objects, such that instances can be compared based on their balance. Use functools.total_ordering. Note: don't worry about checking for valid inputs. You can assume you will get good input. In real life, you would want to do such checking, but that is not the purpose of this exercise.

# Part 3 class BankAccount: "" " Simple BankAccount class """ balance=0): -init-(self, """Initialize account with self . balance = balance def balance""'" def deposit (self, amount): "" "Deposit amount to this account" " " self . balance += amount def withdraw (self, """Withdraw amount from this account""" self . balance -- amount amount)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
