Created
March 11, 2015 03:53
-
-
Save letuananh/44b730ed5955392f6067 to your computer and use it in GitHub Desktop.
Revisions
-
letuananh renamed this gist
Mar 11, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
letuananh created this gist
Mar 11, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ class BankAccount: def __init__(self, initial_balance=0): self.balance = initial_balance def deposit(self,amount): self.balance += amount print("Depositted %s" % (amount,)) def withdraw(self, amount): if amount > self.balance: print("Failed to withdraw %s. You don't have enough cash." % (amount,)) else: self.balance -= amount print("Withdrawn %s" % (amount,)) def get_balance(self): return self.balance def main(): print("Banking demo") b=BankAccount() b.deposit(5000) b.deposit(3000) b.withdraw(10000) b.withdraw(2000) print("Current balance: %s" % (b.get_balance(),)) if __name__ == "__main__": main()