Thread: Post #3

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    3
    Rep Power
    0

    Post #3


    If I run it like this... I still get an error.. How do I define time??

    This is the error I get... Traceback (most recent call last):
    File "C:\Documents and Settings\Alex\Desktop\Module1CASE.py", line 19, in ?
    t = time.localtime(time.time())
    NameError: name 'time' is not defined

    here it is ....

    print "Petty Cash Account Balance"
    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

    a = Account(500000.00)
    a.deposit(550.23)
    a.deposit(5000.50)
    a.deposit(100)
    a.withdraw(50)
    print a.getbalance()

    t = time.localtime(time.time())
    st = time.strftime(" %d-%b-%Y %H:%M:%S", t)

    print t.time()
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Germany
    Posts
    11
    Rep Power
    0
    hi
    don't forget to use the code tags next time

    you must import the time module like this:
    Code:
    import time

IMN logo majestic logo threadwatch logo seochat tools logo