class BankAccount: def withdraw(): pass def deposit(): pass class SavingsAccount(BankAccount): balance = None def __init__(self): self.balance = 500 def deposit(deposit): if deposit < 0: return "Invalid deposit amount" else: self.balance += deposit def withdraw(withdrawal): if self.balance - withdrawal < 500: print 'Cannot withdraw beyond the minimum account balance' elif: withdrawal > self.balance print("Cannot withdraw beyond the minimum account balance") elif: withdrawal < 0 return "Invalid withdraw amount" class CurrentAccount(BankAccount): balance = None def __init__(self): self.balance = 0 def deposit(depositamounts): if depositamounts < 0: return "Invalid deposit amount" self.balance += depositamounts return self.balance def withdraw(cashwithdraw): if cashwithdraw < 0: return Invalid withdraw amount elif: cashwithdraw > self.balance return Cannot withdraw beyond the current account balance else: self.balance -= cashwithdraw return self.balance
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question