1 | class BankAccount(object): |
2 | def __init__(self, initial_balance=0): |
3 | self.balance = initial_balance |
4 | def deposit(self, amount): |
5 | self.balance += amount |
6 | def withdraw(self, amount): |
7 | self.balance -= amount |
8 | def overdrawn(self): |
9 | return self.balance < 0 |
10 | my_account = BankAccount(15) |
11 | my_account.withdraw(5) |
12 | print my_account.balance |
(credit: https://wiki.python.org/moin/SimplePrograms)
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002004 |
Snippet name: | Random Python examples for source parsing |
Eternal ID of this version: | #1002004/1 |
Text MD5: | ef1083599d14c2b675caeb5b2bf4b661 |
Author: | stefan |
Category: | python |
Type: | Document |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-12 19:36:41 |
Source code size: | 378 bytes / 12 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 544 / 522 |
Referenced in: | [show references] |