First, complete the following class definition:
CODE :
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."""
…
The
deposit and withdraw methods each change the account balance. The withdraw method also deducts a fee of 5 dollars from the balance if the withdrawal (before any fees) results in a negative balance. Since we also have the method get_fees, you will need to have a variable to keep track of the fees paid.
Here's one possible test of the class. It should print the values 10 and 5, respectively, since the withdrawal incurs a fee of 5 dollars.
my_account = BankAccount(10)
my_account.withdraw(15)
my_account.deposit(20)
print my_account.get_balance(), my_account.get_fees()
Copy-and-paste the following much longer test. What two numbers are printed at the end? Enter the two numbers, separated only by spaces.
my_account = BankAccount(10)
my_account.withdraw(5)
my_account.deposit(10)
my_account.withdraw(5)
my_account.withdraw(15)
my_account.deposit(20)
my_account.withdraw(5)
my_account.deposit(10)
my_account.deposit(20)
my_account.withdraw(15)
my_account.deposit(30)
my_account.withdraw(10)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(50)
my_account.deposit(30)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(5)
my_account.deposit(20)
my_account.withdraw(15)
my_account.deposit(10)
my_account.deposit(30)
my_account.withdraw(25)
my_account.withdraw(5)
my_account.deposit(10)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(10)
my_account.withdraw(15)
my_account.deposit(10)
my_account.deposit(30)
my_account.withdraw(25)
my_account.withdraw(10)
my_account.deposit(20)
my_account.deposit(10)
my_account.withdraw(5)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(5)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(5)
print my_account.get_balance(), my_account.get_fees()
# http://www.codeskulptor.org/#user25_wvi8CqCpEVvhzVa.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
my_account = BankAccount(10)
my_account.withdraw(15)
my_account.deposit(20)
print my_account.get_balance(), my_account.get_fees()
print "....."
my_account = BankAccount(10)
my_account.withdraw(5)
my_account.deposit(10)
my_account.withdraw(5)
my_account.withdraw(15)
my_account.deposit(20)
my_account.withdraw(5)
my_account.deposit(10)
my_account.deposit(20)
my_account.withdraw(15)
my_account.deposit(30)
my_account.withdraw(10)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(50)
my_account.deposit(30)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(5)
my_account.deposit(20)
my_account.withdraw(15)
my_account.deposit(10)
my_account.deposit(30)
my_account.withdraw(25)
my_account.withdraw(5)
my_account.deposit(10)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(10)
my_account.withdraw(15)
my_account.deposit(10)
my_account.deposit(30)
my_account.withdraw(25)
my_account.withdraw(10)
my_account.deposit(20)
my_account.deposit(10)
my_account.withdraw(5)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(5)
my_account.withdraw(15)
my_account.deposit(10)
my_account.withdraw(5)
print my_account.get_balance(), my_account.get_fees()
print "....."
OUTPUT :
10 5
......
-60 75
......
There's some problem in withdrawal part....... its not showing how much money withdrwan
ReplyDeleteusing account number and value we are withdraw,deposit money how we can withdraw,deposit using account number and value money
ReplyDeleteI like your blog, I read this blog please update more content on python, further check it once at python online training
ReplyDeleteThanks for Sharing a very Informative Post and I Must say its really helpful for us.your blog helps me to know more about the course.
ReplyDeletePython Course in Delhi
Thanks for Sharing a very Informative Post and I Must say its really helpful for.your blog helps me to know more about the course.
Python Course in Noida
Thanks for Sharing a very Informative Post and I Must say its really helpful for.your blog helps me to know more about the course.
Python Course in Gurgaon
This comment has been removed by the author.
ReplyDeleteThanks for sharing such a great blog Keep posting..
ReplyDeletePython Training
Python Course
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
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
email: visacreditcardsolution@gmail.comGET YOUR BLANK ATM CREDIT CARD AT AFFORDABLE PRICE*
ReplyDelete**We sell these cards to all our customers and interested buyers
worldwide,the card has a daily withdrawal limit of $5000 and up to $50,000
spending limit in stores and unlimited on POS.**
**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*