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

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Banking code help, please


    The code below when ii try to run it it gives me a syntax error instead indicating the python version, i have tried other versions but still having the same probe.

    i tried running the program after saving it using the F5 key on the key board, please can someone help me out please.



    Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32
    Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface. This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

    IDLE 1.0
    >>> balance = 0
    >>> def deposit(amount):
    global balance
    balance += amount
    return balance

    >>> def withdraw(amount)
    SyntaxError: invalid syntax
    >>> def withdraw(amount):
    global balance
    balance -= amount
    return ()

    >>> def make_account():
    return {'balance' : 0}

    >>> def deposit(account, amount):
    account['balance'] += amount
    return account['balance']

    >>> def withdraw(account, amount):
    account['balance'] -= amount
    return account['balance']

    >>> def _init_(self):
    self.balance = 0


    >>> def withdraw(self, amount):
    self.balance -= amount
    return self.balance

    >>> def deposit(self, amount):
    self.balance += amount
    return self.balance

    >>> a = BankAccount()

    Traceback (most recent call last):
    File "<pyshell#35>", line 1, in -toplevel-
    a = BankAccount()
    NameError: name 'BankAccount' is not defined
    >>> class Canvas:
    def _init_(self, width, height):
    self.width = width
    self.height = height
    self.data = [[' '] * width for i in range(height)]


    >>> def setpixel(self, row, col):
    self.data[row][col] = '*'


    >>> def getpixel(self, row, col):
    return self.data[row][col]

    >>> def display(self):
    print "\n".join(["".join(row) for row in self.data])


    >>> class shape:
    def paint(self, convas): pass


    >>> class Rectangle(Shape):
    def _init_(self, x, y, w, h):
    self.x = x
    self.y = y
    self.w = w
    self.h = h



    Traceback (most recent call last):
    File "<pyshell#60>", line 1, in -toplevel-
    class Rectangle(Shape):
    NameError: name 'Shape' is not defined
    >>>


    >>> class Rectangle(shape):
    def _init_(self, x, y, w, h):
    self.x = x
    self.y = y
    self.w = w
    self.h = h

    SyntaxError: invalid syntax
    >>> class Rectangle(shape):
    def _init_(self, x, y, w, h):
    self.x = x
    self.y = y
    self.w = w
    self.h = h


    >>> def hline(self, x, y, w):
    pass

    >>> def vline(self, x, y, h):
    pass

    >>> def paint(self, canvas):
    hline(self.x, self.y self.w)

    SyntaxError: invalid syntax
    >>> def paint(self, canvas):
    hline(self.x, self.y, self.w)
    hline(self.x, self.y + self.h, self.w)
    vline(self.x + self.w, self.y, self.h)


    >>> class Square(rectangle):
    def _init_(self, x, y, size):
    Rectangle._init_(self, x, y, size, size)



    Traceback (most recent call last):
    File "<pyshell#85>", line 1, in -toplevel-
    class Square(rectangle):
    NameError: name 'rectangle' is not defined
    >>> class Square(rectangle):
    def _init_(sefl, x, y, size):
    rectangle._init_(self, x, y, size, size)



    Traceback (most recent call last):
    File "<pyshell#89>", line 1, in -toplevel-
    class Square(rectangle):
    NameError: name 'rectangle' is not defined
    >>> class CompoundShape(Shape):
    def _init_(self, shapes):
    self.shapes = shapes



    Traceback (most recent call last):
    File "<pyshell#93>", line 1, in -toplevel-
    class CompoundShape(Shape):
    NameError: name 'Shape' is not defined
    >>> class CompountShape(shape):
    def _init_(self, shapes):
    self.shapes = shapes


    >>> def paint(self, canvas):
    for s in self.shapes:
    s.paint(canvas)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    491
    Rep Power
    33
    Go to this page where the examples came from and run them one at a time in the order given. They are meant to be separate examples, not run all at once.

IMN logo majestic logo threadwatch logo seochat tools logo