Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [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.2.1 ==== No Subprocess ==== >>> >>> >>> factorial(4) 24 >>> >>> factWhile(4) >>> >>> factWhile(4) 12 >>> >>> factWhile(4) 24 >>> while bob = 2 SyntaxError: invalid syntax >>> num = raw_input("Enter a number: ") Enter a number: sdafjkhasdjkfhajk >>> float(num) Traceback (most recent call last): File "", line 1, in float(num) ValueError: invalid literal for float(): sdafjkhasdjkfhajk >>> [1, 2, 3] [1, 2, 3] >>> (1, 2, 3) (1, 2, 3) >>> t = (1, 2, 3) >>> t[2] = 23423 Traceback (most recent call last): File "", line 1, in t[2] = 23423 TypeError: 'tuple' object does not support item assignment >>> array = [0,12,3] >>> array[0:1] [0] >>> array[0:2] [0, 12] >>> a = array[0:2] >>> a [0, 12] >>> array = [0,1,2,3,4,5,6] >>> array[::-1] [6, 5, 4, 3, 2, 1, 0] >>> array[1:0] [] >>> array[1:] [1, 2, 3, 4, 5, 6] >>> array[:2] [0, 1] >>> string = "Hello World!" >>> stringp[2:5] Traceback (most recent call last): File "", line 1, in stringp[2:5] NameError: name 'stringp' is not defined >>> string[3:5] 'lo' >>> array[::] [0, 1, 2, 3, 4, 5, 6] >>> array [0, 1, 2, 3, 4, 5, 6] >>> array[::-1] [6, 5, 4, 3, 2, 1, 0] >>> array[2:5] [2, 3, 4] >>> >>> function(6) 11 >>> >>> function(6) 11 >>> x = function(6) 11 >>> x >>> type(x) >>> string = "Your age is: %d" % 18 >>> string 'Your age is: 18' >>> string = "%s. The lucky number is %d. A float is %f" % ("Hello", 2, 2.385) >>> string 'Hello. The lucky number is 2. A float is 2.385000' >>> string = "%s. The lucky number is %d. A float is %.2f" % ("Hello", 2, 2.385) >>> string 'Hello. The lucky number is 2. A float is 2.38'