Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 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.1 >>> ================================ RESTART ================================ >>> Traceback (most recent call last): File "C:/Python24/feb15.py", line 9, in -toplevel- s.push(1) TypeError: push() takes exactly 1 argument (2 given) >>> ================================ RESTART ================================ >>> Traceback (most recent call last): File "C:/Python24/feb15.py", line 9, in -toplevel- s.push(1) File "C:/Python24/feb15.py", line 6, in push self.items = item + self.items TypeError: unsupported operand type(s) for +: 'int' and 'list' >>> ================================ RESTART ================================ >>> >>> s <__main__.Stack instance at 0x00B456C0> >>> print s <__main__.Stack instance at 0x00B456C0> >>> str(s) '<__main__.Stack instance at 0x00B456C0>' >>> ================================ RESTART ================================ >>> >>> s <__main__.Stack instance at 0x00B45670> >>> print s [1, 3, 4] >>> ================================ RESTART ================================ >>> >>> print s [1, 3, 4] >>> s.top() 1 >>> s.pop() >>> print s [3, 4] >>> s.pop() >>> prin s SyntaxError: invalid syntax >>> print s [4] >>> s.top() 4 >>> print s [4] >>> s.pop() >>> print s [] >>> s.top() Traceback (most recent call last): File "", line 1, in -toplevel- s.top() File "C:/Python24/feb15.py", line 15, in top return self.items[0] IndexError: list index out of range >>> ================================ RESTART ================================ >>> >>> s.isEmpty() False >>> s.pop() >>> s.pop() >>> s.isEmpty() False >>> print s [4] >>> s.pop() >>> s.isEmpty() True >>> ================================ RESTART ================================ >>> >>> s.pop( ) >>> s.pop() >>> s.pop() >>> s.pop() >>> print s >>> print s [] >>> s.pop() >>> ================================ RESTART ================================ >>> >>> s.pop() >>> s.pop() >>> s.pop() >>> print s [] >>> s.pop() >>> s.top() Traceback (most recent call last): File "", line 1, in -toplevel- s.top() File "C:/Python24/feb15.py", line 20, in top raise IndexError IndexError >>> ================================ RESTART ================================ >>> >>> s.pop() >>> s.pop() >>> s.pop() >>> s.pop() Traceback (most recent call last): File "", line 1, in -toplevel- s.pop() File "C:/Python24/feb15.py", line 14, in pop raise IndexError IndexError >>> s.push(4) >>> print s [4] >>> s.push("alkjhfd") >>> print s ['alkjhfd', 4] >>> ================================ RESTART ================================ >>> >>> s.push(4) >>> print s [4, 1, 3, 4] >>> s.push("ksdnf") Traceback (most recent call last): File "", line 1, in -toplevel- s.push("ksdnf") File "C:/Python24/feb15.py", line 10, in push raise TypeError TypeError >>> ================================ RESTART ================================ >>> >>> s.push(4) >>> s.push("lkshg") Traceback (most recent call last): File "", line 1, in -toplevel- s.push("lkshg") File "C:/Python24/feb15.py", line 10, in push raise TypeError TypeError >>> ================================ RESTART ================================ >>> Traceback (most recent call last): File "C:/Python24/feb15.py", line 63, in -toplevel- q.push(8) File "C:/Python24/feb15.py", line 40, in push self.items = [item] + self.items TypeError: can only concatenate list (not "NoneType") to list >>> ================================ RESTART ================================ >>> >>> print q [10, 8] >>> q.pop() >>> print q [10] >>> q.push(8) >>> print q [8, 10] >>> q.top() 10 >>> ================================ RESTART ================================ >>> >>> node1 = Node(15) >>> node2 = Node(5) >>> node3 = Node(25) >>> node4 = Node(30) >>> node1.left = node2 >>> node1.right = node3 >>> node3.right = node4 >>> print_tree(node1) 15 5 25 30 >>>