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
(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: | 505 / 508 |
Referenced in: | [show references] |