Skip to content

Instantly share code, notes, and snippets.

@jimmykurian
Created February 6, 2012 16:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save jimmykurian/1753188 to your computer and use it in GitHub Desktop.
Save jimmykurian/1753188 to your computer and use it in GitHub Desktop.
A BankAccount program with classes, written in Python.
# BankAccount.py - Jimmy Kurian
class BankAccount(object):
def __init__(self, initial_balance=0):
self.balance = initial_balance
def deposit(self, amount):
self.balance += amount
def withdraw(self, amount):
self.balance -= amount
def overdrawn(self):
return self.balance < 0
my_account = BankAccount(15)
my_account.withdraw(5)
print my_account.balance
@Dailydelight
Copy link

This is a simple perfect code but what about creating a subclass which inherits properties of class BankAccount with the name MinimumBalance?

@amritasony251
Copy link

there is no link between object and balance used here! I didn't get how this program is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment