[Tutor] Need Help
Luke Paireepinart
rabidpoobear at gmail.com
Tue Jul 11 13:41:23 CEST 2006
Hi.
Shappell, John J CW2 wrote:
>
> Here is the assignment
>
[snip assignment]
Please don't ask about homework in the future. Did your professor tell
you to submit queries to this list? If so, could you ask him not to?
it's against the policies of the tutor mailing list to give homework
help. However, I can give you a few hints about python in general. The
rules may be different but my impression was that there was no homework
to be submitted here. If I'm wrong please correct me.
>
> This is where I am at so far. I don't understand how to get the
> Account class into the program. Can you help a little, Just looking
> for an idea or some guidance
>
> #!/usr/bin/python
> # Filename: petty cash.py
>
> print "Welcome to the petty cash account"
> print "Did you deposit or withdrawl money today"
>
> print
>
> # print out menu
> print "please select a number"
> print "1 for deposit"
> print "2 for withdrawl"
>
> # Get user's choice:
> number = input (">")
>
I suggest doing something like
number = int(raw_input("> "))
I'm pretty sure the 'input' statement is a no-no, unless your Professor
says, and then you should use it.
>
> #
> if number == 1:
> deposit = input ("how much?")
> print "I deposited:", deposit
>
> elif number == 2:
> withdrawl = input ("How Much?")
> print "I withdrew:", withdrawl
>
> print "what is today's date?"
> # Get date from user
> date = input (">")
>
> *This is where I get stuck. The program will allow me to input the
> deposit or withdrawl ammount and the date but does nothing ownce it
> gets here*
>
> class Account:
> def __init__(self, initial):
> self.balance = initial
> def deposit(self, amt):
> self.balance = self.balance + amt
> def withdraw(self,amt):
> self.balance = self.balance - amt
> def getbalance(self):
> return self.balance
>
What you have there is a class, not an instance of a class. read more
about the difference at http://www.python.org/doc/2.2.3/tut/node11.html
or some other tutorial site.
Also, make it clear to your instructor that you had trouble here. If he
doesn't know what's hanging people up he won't be able to help you with it.
>
> john.shappell at campbell.army.mil
> john.j.shappelljr at us.army.mil
>
What was your job in the Army, if you don't mind my asking?
Cheers.
-Luke
More information about the Tutor
mailing list