We will again use the
BankAccount class from the previous problem. You should be able to use the same definition for both problems.
Of course, a bank with only one account will go out of business, so we want our
BankAccount class to work correctly with many accounts. Naturally, each bank account should have its own balance, with deposits and withdrawals going to the appropriate account. Similarly, the penalty fees for each account should be kept separate.class BankAccount:
def __init__(self, initial_balance):
"""Creates an account with the given balance."""
…
def deposit(self, amount):
"""Deposits the amount into the account."""
…
def withdraw(self, amount):
"""
Withdraws the amount from the account. Each withdrawal resulting in a
negative balance also deducts a penalty fee of 5 dollars from the balance.
"""
…
def get_balance(self):
"""Returns the current balance in the account."""
…
def get_fees(self):
"""Returns the total fees ever deducted from the account."""
…
Here's one possible test with multiple accounts. It should print the values 10, 5, 5, and 0.
account1 = BankAccount(10)
account1.withdraw(15)
account2 = BankAccount(15)
account2.deposit(10)
account1.deposit(20)
account2.withdraw(20)
print account1.get_balance(), account1.get_fees(), account2.get_balance(), account2.get_fees()
Copy-and-paste the following much longer test. What four numbers are printed at the end? Enter the four numbers, separated only by spaces.
account1 = BankAccount(20)
account1.deposit(10)
account2 = BankAccount(10)
account2.deposit(10)
account2.withdraw(50)
account1.withdraw(15)
account1.withdraw(10)
account2.deposit(30)
account2.withdraw(15)
account1.deposit(5)
account1.withdraw(10)
account2.withdraw(10)
account2.deposit(25)
account2.withdraw(15)
account1.deposit(10)
account1.withdraw(50)
account2.deposit(25)
account2.deposit(25)
account1.deposit(30)
account2.deposit(10)
account1.withdraw(15)
account2.withdraw(10)
account1.withdraw(10)
account2.deposit(15)
account2.deposit(10)
account2.withdraw(15)
account1.deposit(15)
account1.withdraw(20)
account2.withdraw(10)
account2.deposit(5)
account2.withdraw(10)
account1.deposit(10)
account1.deposit(20)
account2.withdraw(10)
account2.deposit(5)
account1.withdraw(15)
account1.withdraw(20)
account1.deposit(5)
account2.deposit(10)
account2.deposit(15)
account2.deposit(20)
account1.withdraw(15)
account2.deposit(10)
account1.deposit(25)
account1.deposit(15)
account1.deposit(10)
account1.withdraw(10)
account1.deposit(10)
account2.deposit(20)
account2.withdraw(15)
account1.withdraw(20)
account1.deposit(5)
account1.deposit(10)
account2.withdraw(20)
print account1.get_balance(), account1.get_fees(), account2.get_balance(), account2.get_fees()
CODE :# http://www.codeskulptor.org/#user25_e4TY2qlXm9gkKEk.py
class BankAccount:
def __init__(self, initial_balance):
"""Creates an account with the given balance."""
self.money = initial_balance
self.penalty = 0
def deposit(self, amount):
"""Deposits the amount into the account."""
self.money += amount
return self.money
def withdraw(self, amount):
"""
Withdraws the amount from the account. Each withdrawal resulting in a
negative balance also deducts a penalty fee of 5 dollars from the balance.
"""
if self.money - amount < 0:
self.money -= amount+5
self.penalty += 5
else:
self.money -= amount
return self.money
def get_balance(self):
"""Returns the current balance in the account."""
return self.money
def get_fees(self):
"""Returns the total fees ever deducted from the account."""
return self.penalty
account1 = BankAccount(10)
account1.withdraw(15)
account2 = BankAccount(15)
account2.deposit(10)
account1.deposit(20)
account2.withdraw(20)
print account1.get_balance(), account1.get_fees(), account2.get_balance(), account2.get_fees()
print"..............."
account1 = BankAccount(20)
account1.deposit(10)
account2 = BankAccount(10)
account2.deposit(10)
account2.withdraw(50)
account1.withdraw(15)
account1.withdraw(10)
account2.deposit(30)
account2.withdraw(15)
account1.deposit(5)
account1.withdraw(10)
account2.withdraw(10)
account2.deposit(25)
account2.withdraw(15)
account1.deposit(10)
account1.withdraw(50)
account2.deposit(25)
account2.deposit(25)
account1.deposit(30)
account2.deposit(10)
account1.withdraw(15)
account2.withdraw(10)
account1.withdraw(10)
account2.deposit(15)
account2.deposit(10)
account2.withdraw(15)
account1.deposit(15)
account1.withdraw(20)
account2.withdraw(10)
account2.deposit(5)
account2.withdraw(10)
account1.deposit(10)
account1.deposit(20)
account2.withdraw(10)
account2.deposit(5)
account1.withdraw(15)
account1.withdraw(20)
account1.deposit(5)
account2.deposit(10)
account2.deposit(15)
account2.deposit(20)
account1.withdraw(15)
account2.deposit(10)
account1.deposit(25)
account1.deposit(15)
account1.deposit(10)
account1.withdraw(10)
account1.deposit(10)
account2.deposit(20)
account2.withdraw(15)
account1.withdraw(20)
account1.deposit(5)
account1.deposit(10)
account2.withdraw(20)
print account1.get_balance(), account1.get_fees(), account2.get_balance(), account2.get_fees()
print"..............."
OUTPUT :
10 5 5 0 ............... -55 45 45 20 ...............
Read our casino game review about 50 lions slots and get exclusive bonuses here on realmoneyslotstmz.com
ReplyDelete
ReplyDeleteI got my already programmed and blanked ATM card to withdraw the maximum of $50,000 daily for a maximum of 20 days. I am so happy about this because i got mine last week and I have used it to get $100,000. Skylink technologies is giving out the card just to help the poor and needy though it is illegal but it is something nice and they're not like other scam pretending to have the blank ATM cards. And no one gets caught when using the card. get yours today
Just send them an email On skylinktechnes@yahoo.com whatsapp: +1(213)785-1553 or website: https://skylinktechnes.wixsite.com/info
HOW TO GET BLANK ATM CARD AND WITHDRAW
ReplyDeleteUNLIMITED CASH
This is the happiest moment of my life having no longer to worry about paying bills as i have been settled for life. A lot has been said about atm hacking and blank card for cash withdrawal but it all seemed like a myth to me until i eventually lost my job few months back and the world seemed to be moving backwards. I went online in search of jobs and means to an end and there i found comments about blankatmdeliveryxpress and how they deliver this card in less than 7 days with no risk involved and a far much lesser price compared to what the card itself can give you, i then made contact and purchase one from them with almost my last dollars I took the risk and in exactly 6 days latter my card and a manual was delivered to my home address here in California and that same evening i used the card was able to take out $5000 for a start its been just 3 weeks and my life has taken a new shape. I simply want to say thank you to this electronic company and help spread their fame abroad. If you ever are in need of this card contact them via email :blankatmdeliveryxpress@gmail.com.
Don't mail them if you not really ready for this card is gonna cost you money to buy the card note that,they offer card to firms, orphans,individual and business personnels mail them immediately .
Are you in a financial crisis, looking for money to start your own business or to pay your bills?
ReplyDeleteGET YOUR BLANK ATM CREDIT CARD AT AFFORDABLE PRICE*
We sell this cards to all our customers and interested buyers
worldwide,Tho card has a daily withdrawal limit of $5000 and up to $50,000
spending limit in stores and unlimited on POS.
YOU CAN ALSO MAKE BINARY INVESTMENTS WITH LITTLE AS $500 AND GET $10,000 JUST IN SEVEN DAYS
**WHAT WE OFFER**
*1)WESTERN UNION TRANSFERS/MONEY GRAM TRANSFER*
*2)BANKS LOGINS*
*3)BANKS TRANSFERS*
*4)CRYPTO CURRENCY MINNING*
*5)BUYING OF GIFT CARDS*
*6)LOADING OF ACCOUNTS*
*7)WALMART TRANSFERS*
*8)BITCOIN INVESTMENTS*
*9)REMOVING OF NAME FROM DEBIT RECORD AND CRIMINAL RECORD*
*10)BANK HACKING*
**email blankatmmasterusa@gmail.com *
**you can also call or whatsapp us Contact us today for more enlightenment *
*+1(539) 888-2243*
**BEWARE OF SCAMMERS AND FAKE HACKERS IMPERSONATING US BUT THEY ARE NOT
FROM *
*US CONTACT US ONLY VIA THIS CONTACT **
*WE ARE REAL AND LEGIT...........
2020 FUNDS/FORGET ABOUT GETTING A LOAN..*
IT HAS BEEN TESTED AND TRUSTED
INSTEAD OF GETTING A LOAN, CHECK OUT THE BLANK ATM CARD IN LESS THAN 24hours {oscarwhitehackersworld@gmail.com}
ReplyDeleteI want to testify about OSCAR WHITE blank ATM cards which can withdraw money from any ATM machines around the world. I was very poor before and have no hope then I saw so many testimony about how OSCAR WHITE send them the blank ATM card and i use it to collect money in any ATM machine and become rich. I also email him and he sent me the blank card. I have use it to get $100,000 dollars. withdraw the maximum of $5,000 daily.OSCAR WHITE is giving out the card just to help the poor. Hack and take money directly from any ATM Machine Vault with the use of ATM Programmed Card which runs in automatic mode. email Him on how to get it now via: oscarwhitehackersworld@gmail.com or whats-app +1(323)-362-2310