Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BankAccount:
- """ Class definition modeling the behavior of a simple bank account """
- balance = 0
- def __init__(self, balance):
- """Creates an account with the given balance."""
- def deposit(self, amount):
- """Deposits the amount into the account."""
- return balance + amount
- 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.
- """
- fees_paid = 0
- if balance > amount:
- return balance - amount
- else:
- return balance - amount - 5
- fees_paid = feed_paid + 5
- def get_balance(self):
- """Returns the current balance in the account."""
- return balance
- def get_fees(self):
- """Returns the total fees ever deducted from the account."""
- return fees_paid
- my_account = BankAccount(10)
- my_account.withdraw(15)
- my_account.deposit(20)
- print my_account.get_balance(), my_account.get_fees()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement