Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "copyright", "credits" or "license()" for more information. >>> def multiplication_table (high_num): for num1 in range(1, 1+high_num): for num2 in range(1, 1+high_num): print(num1,'X',num2, '=', num1*num2) >>> multiplication_table(5) 1 X 1 = 1 1 X 2 = 2 1 X 3 = 3 1 X 4 = 4 1 X 5 = 5 2 X 1 = 2 2 X 2 = 4 2 X 3 = 6 2 X 4 = 8 2 X 5 = 10 3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 3 X 4 = 12 3 X 5 = 15 4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 4 X 5 = 20 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 >>> def mutliply_one_set(number): for num in range(1,number+1): print(number,'X',num, '=', number*num) >>> def multiply_one_set(number): for num in range(1,number+1): print(number,'X',num, '=', number*num) >>> multiply_one_set(5) 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 >>> def multiply_one_set(number,num1): for num2 in range(1,number+1): print(num1,'X',num2, '=', num1*num2) >>> multiply_one_set(5,5) 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 >>> multiply_one_set(5,2) 2 X 1 = 2 2 X 2 = 4 2 X 3 = 6 2 X 4 = 8 2 X 5 = 10 >>> def multiplication_table1 (high_num): for num1 in range(1, 1+high_num): multiply_one_set(high_num,num1) >>> multiplication_table1(5) 1 X 1 = 1 1 X 2 = 2 1 X 3 = 3 1 X 4 = 4 1 X 5 = 5 2 X 1 = 2 2 X 2 = 4 2 X 3 = 6 2 X 4 = 8 2 X 5 = 10 3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 3 X 4 = 12 3 X 5 = 15 4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 4 X 5 = 20 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 >>> ================================ RESTART ================================ >>> >>> make_checkerboard() >>> ================================ RESTART ================================ >>> >>> make_checkerboard() >>> ================================ RESTART ================================ >>> >>> wacky_bars2(43,103,15,17) >>> import random >>> random.random() 0.13276854742320754 >>> random.random() 0.16640710840267925 >>> random.random()*255 89.34792015275445 >>> random.random()*255 233.71585766904133 >>> random.random()*255 153.8058735290814 >>> import math >>> math.ceil(random.random()*255) 138 >>> ================================ RESTART ================================ >>> def functiona(x): return(5) >>> def functionb(x): return(10) >>> functiona() Traceback (most recent call last): File "", line 1, in functiona() TypeError: functiona() takes exactly 1 positional argument (0 given) >>> functiona(100) 5 >>> funcitonb(100) Traceback (most recent call last): File "", line 1, in funcitonb(100) NameError: name 'funcitonb' is not defined >>> functionb(100) 10 >>> functiona(100)+functionb(100) 15 >>> sample_string = 'There are several escape characters including \n (newline) and \' and \t (tab)' >>> sample_string "There are several escape characters including \n (newline) and ' and \t (tab)" >>> print(sample_string) There are several escape characters including (newline) and ' and (tab) >>> 5/10 0.5 >>> 10/5 2.0 >>> 10//5 2 >>> 20.0//5.0 4.0 >>> 21.0//5.0 4.0 >>> 21.0/5.0 4.2 >>> -5/2 -2.5 >>> -5//2 -3 >>> int('5') 5 >>> float('5.1') 5.1 >>> float(5) 5.0 >>> int(5.7) 5 >>> int(-5.7) -5 >>> int('5.0') Traceback (most recent call last): File "", line 1, in int('5.0') ValueError: invalid literal for int() with base 10: '5.0' >>> float('5') 5.0 >>> print(5) 5 >>> 5+',' Traceback (most recent call last): File "", line 1, in 5+',' TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> str(5)+',' '5,' >>> output Traceback (most recent call last): File "", line 1, in output NameError: name 'output' is not defined >>> output = 5 >>> output 5 >>> 5 == 2 + 3 True >>> 5 = 2+3 SyntaxError: can't assign to literal >>> def plus(x,y): return(x+y) >>> plus(5,5) 10 >>> 10%7 3 >>> for number in range(14): print(number,number%7) 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 0 8 1 9 2 10 3 11 4 12 5 13 6 >>> 50%7 1 >>> 'a' in 'abcdefg' True >>> 1 in [1,2,3] True >>> 'a' in 'frog' False >>> range(4) range(0, 4) >>> 4 in range(4) False >>> 3 in range(4) True >>> output = 7 >>> plus(output,5) 12 >>> def classify_integer(integer): if integer==0: return('zero') elif (integer%2) == 0: return('even') else: return('odd') >>> classify_integer(203) 'odd' >>> 203%2 1 >>> classify_integer(0) 'zero' >>> classify_integer(34) 'even' >>> def diagonal_print(word): number = 0 for letter in word: print(number*' ',letter,sep='') number=number+1 >>> diagonal_print('hello') h e l l o >>>