It's a simple bank-type transaction program. User needs to input
initial starting balance, amount of deposits, amount of withdrawals.
Program needs to do the appropriate math and return status update
showing new balance, total deposits and total withdrawals.
I keep coming up with 2 different results...1 returns an error message
and the other finishes the program but the mathmematics is wrong (it
does not compute deposits and withdrawlas. It only returns intial
balance as new balance.)
Code for error message return is:
(formal code)
from Account import Account
from datetime import date
a = Account()
now = date.today()
print "As of",now,"balance is $",a.getbalance()
(class code)
class Account:
def __init__(self, initial):
self.balance = initial
def deposit(self, amt):
self.balance = balance + amt
def withdraw(new, amt):
self.balance = balance - amt
def getbalance(self):
return self.balance
Error message that gets returned is:
Traceback (most recent call last):
File "C:\Python23\Module1a.py", line 4, in -toplevel-
a = Account()
TypeError: __init__() takes exactly 2 arguments (1 given)
The code that returns new balance only is:
(class code)
class Account:
def __init__(self, balance):
self.balance = balance
def deposit(self, deposit):
self.balance = self.balance + deposit
def withdraw(self, withdraw):
self.balance = self.balance - withdraw
def getbalance(self, balance):
self.balance = bal + deposit - withdraw
return self.balance
(formal code)
from account1a import Account
from datetime import date
now = date.today()
a = Account()
bal = input("Enter amount of starting balance: $")
dpst = input("Enter amount of deposit: $")
wdrw = input("Enter amount of withdrawal: $")
print "As of",now,"balance is $",a.getbalance()
Appreciate all the assistance I might get.
"Larry Bates" <lb****@swamisoft.com> wrote in message news:<oK********************@comcast.com>...
You really should post what you have tried and
any traceback error messages of things that didn't
work. A little background explanation of what you
are trying to do would also be nice. It's impossible
for us to venture a guess as to what you might be
doing wrong or to suggest a methodology without this
information.
Regards,
Larry Bates
Syscon, Inc.
"Crypt Keeper" <cr**********@rome.com> wrote in message
news:29**************************@posting.google.c om... I am trying to write a program that asks user for several input items,
then takes those items into a class that will manipulate the data and
then return a line of output. I am able to input the reuired
information, but it's the in-class processing and output line that
keeps messing up somehow. I have tried tinkering and tweaking but with
no success.
How can I take data from the user, manipulate it through a class of
steps and then output it all into a line of output?
Thanks!!