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. >>> ================================ RESTART ================================ >>> >>> output = [] >>> output = choose_a_number_of_random_ints_less_than1000(1,10) Traceback (most recent call last): File "", line 1, in output = choose_a_number_of_random_ints_less_than1000(1,10) NameError: name 'choose_a_number_of_random_ints_less_than1000' is not defined >>> output = choose_a_random_number_of_random_ints_less_than1000(1,10) >>> output [629, 53] >>> output = choose_a_random_number_of_random_ints_less_than1000(1,30) >>> output [572, 235, 768, 902, 255, 307, 321, 221, 977, 52, 818, 491, 392, 326, 549, 964, 308] >>> ================================ RESTART ================================ >>> >>> find_highest_number(output) Traceback (most recent call last): File "", line 1, in find_highest_number(output) NameError: name 'output' is not defined >>> output = choose_a_random_number_of_random_ints_less_than1000(1,30) Traceback (most recent call last): File "", line 1, in output = choose_a_random_number_of_random_ints_less_than1000(1,30) NameError: name 'choose_a_random_number_of_random_ints_less_than1000' is not defined >>> import os >>> os.getcwd() '/Users/adam/Desktop/Summer 2011 Scripts' >>> import recursion_functions.py Traceback (most recent call last): File "", line 1, in import recursion_functions.py ImportError: No module named recursion_functions.py >>> ================================ RESTART ================================ >>> >>> def find_highest_number(in_list): print(in_list) length = len(in_list) if length == 1: return(in_list[0]) elif length == 2: if in_list[0] > in_list[1]: return(in_list[0]) else: return(in_list[1]) else: mid_point = length//2 list1 = in_list[:mid_point] list2 = in_list[mid_point:] high1 = find_highest_number(list1) high2 = find_highest_number(list2) if high1 > high2: return(high1) else: return(high2) >>> output = choose_a_random_number_of_random_ints_less_than1000(1,30) >>> output [849, 576, 938, 541, 896, 395, 23, 723, 231, 689, 984, 521, 294, 900, 861, 367, 818, 201, 141, 639, 833, 681] >>> find_highest_number(output) [849, 576, 938, 541, 896, 395, 23, 723, 231, 689, 984, 521, 294, 900, 861, 367, 818, 201, 141, 639, 833, 681] [849, 576, 938, 541, 896, 395, 23, 723, 231, 689, 984] [849, 576, 938, 541, 896] [849, 576] [938, 541, 896] [938] [541, 896] [395, 23, 723, 231, 689, 984] [395, 23, 723] [395] [23, 723] [231, 689, 984] [231] [689, 984] [521, 294, 900, 861, 367, 818, 201, 141, 639, 833, 681] [521, 294, 900, 861, 367] [521, 294] [900, 861, 367] [900] [861, 367] [818, 201, 141, 639, 833, 681] [818, 201, 141] [818] [201, 141] [639, 833, 681] [639] [833, 681] 984 >>> def find_highest_number(in_list): print('input',in_list) length = len(in_list) if length == 1: print(in_list,'output',in_list[0]) return(in_list[0]) elif length == 2: if in_list[0] > in_list[1]: print(in_list,'output',in_list[0]) return(in_list[0]) else: print(in_list,'output',in_list[1]) return(in_list[1]) else: mid_point = length//2 list1 = in_list[:mid_point] list2 = in_list[mid_point:] high1 = find_highest_number(list1) high2 = find_highest_number(list2) if high1 > high2: print(in_list,'output',high1) return(high1) else: print(in_list,'output',high2) return(high2) >>> find_highest_number(output) input [849, 576, 938, 541, 896, 395, 23, 723, 231, 689, 984, 521, 294, 900, 861, 367, 818, 201, 141, 639, 833, 681] input [849, 576, 938, 541, 896, 395, 23, 723, 231, 689, 984] input [849, 576, 938, 541, 896] input [849, 576] [849, 576] output 849 input [938, 541, 896] input [938] [938] output 938 input [541, 896] [541, 896] output 896 [938, 541, 896] output 938 [849, 576, 938, 541, 896] output 938 input [395, 23, 723, 231, 689, 984] input [395, 23, 723] input [395] [395] output 395 input [23, 723] [23, 723] output 723 [395, 23, 723] output 723 input [231, 689, 984] input [231] [231] output 231 input [689, 984] [689, 984] output 984 [231, 689, 984] output 984 [395, 23, 723, 231, 689, 984] output 984 [849, 576, 938, 541, 896, 395, 23, 723, 231, 689, 984] output 984 input [521, 294, 900, 861, 367, 818, 201, 141, 639, 833, 681] input [521, 294, 900, 861, 367] input [521, 294] [521, 294] output 521 input [900, 861, 367] input [900] [900] output 900 input [861, 367] [861, 367] output 861 [900, 861, 367] output 900 [521, 294, 900, 861, 367] output 900 input [818, 201, 141, 639, 833, 681] input [818, 201, 141] input [818] [818] output 818 input [201, 141] [201, 141] output 201 [818, 201, 141] output 818 input [639, 833, 681] input [639] [639] output 639 input [833, 681] [833, 681] output 833 [639, 833, 681] output 833 [818, 201, 141, 639, 833, 681] output 833 [521, 294, 900, 861, 367, 818, 201, 141, 639, 833, 681] output 900 [849, 576, 938, 541, 896, 395, 23, 723, 231, 689, 984, 521, 294, 900, 861, 367, 818, 201, 141, 639, 833, 681] output 984 984 >>> get_descendants('Victoria') ['Edward VII', 'Princess Alice', 'George V', 'Edward VIII', 'George VI', 'Princess Mary II', 'Henry, Duke of Gloucester', 'George, Duke of Kent', 'Prince John', 'Elizabeth II', 'Princess Margaret', 'Prince Charles', 'Princess Anne', 'Prince Andrew', 'Prince Edward', 'Prince William of Wales', 'Prince Henry of Wales', 'Peter Phillips', 'Zara Phillips', 'Princess Beatrice', 'Princess Eugenie', 'Lady Louise Windsor', 'Viscount Severn', 'David, Viscount of Linley', 'Lady Sarah Armstrong Jones', 'Charles Armstrong Jones', 'Margarita Armstrong Jones', 'Samuel Chatto', 'Arthur Chatto', 'Prince William', 'Richard, Duke of Gloucester', 'Alexander, Earl of Ulster', 'Lady Davina Lewis', 'Lady Rose Gilman', 'Edward, Duke of Kent', 'Princess Alexandra II', 'Prince Michael', 'George, Earl of St. Lewis', 'Lady Helen Windsor', 'Lord Nicholas Windsor', 'Edward Baron Downpatrick', 'Lady Marina Windsor', 'Lady Amelia Windsor', 'Columbus Taylor', 'Cassius Taylor', 'Eloise Taylor', 'Estella Taylor', 'James Ogilvy', 'Marina Ogilvy', 'Flora Ogilvy', 'Alexander Ogilvy', 'Zenouska Mowatt', 'Christian Mowatt', 'Princess Victoria', 'Princess Alice II', 'Phillip, Duke of Edinburgh', 'Prince Charles', 'Princess Anne', 'Prince Andrew', 'Prince Edward', 'Prince William of Wales', 'Prince Henry of Wales', 'Peter Phillips', 'Zara Phillips', 'Princess Beatrice', 'Princess Eugenie', 'Lady Louise Windsor', 'Viscount Severn'] >>> get_descendants('Elizabeth II') ['Prince Charles', 'Princess Anne', 'Prince Andrew', 'Prince Edward', 'Prince William of Wales', 'Prince Henry of Wales', 'Peter Phillips', 'Zara Phillips', 'Princess Beatrice', 'Princess Eugenie', 'Lady Louise Windsor', 'Viscount Severn'] >>> get_nth_ancestors('Prince William',1) ['Henry, Duke of Gloucester', 'Lady Alice Montague'] >>> get_nth_ancestors('Prince William of Wales',1) ['Prince Charles', 'Lady Diana'] >>> get_nth_ancestors('Prince William of Wales',2) ['Elizabeth II', 'Phillip, Duke of Edinburgh'] >>> get_nth_descendants('Elizabeth II',1) ['Prince Charles', 'Princess Anne', 'Prince Andrew', 'Prince Edward'] >>> get_nth_descendants('Elizabeth II',2) ['Prince William of Wales', 'Prince Henry of Wales', 'Peter Phillips', 'Zara Phillips', 'Princess Beatrice', 'Princess Eugenie', 'Lady Louise Windsor', 'Viscount Severn'] >>> ================================ RESTART ================================ >>> EVENTLOOP >>> ================================ RESTART ================================ >>> EVENTLOOP >>> ================================ RESTART ================================ >>> EVENTLOOP >>> ================================ RESTART ================================ >>> EVENTLOOP >>> ================================ RESTART ================================ >>> EVENTLOOP >>> ================================ RESTART ================================ >>> EVENTLOOP >>> ================================ RESTART ================================ >>>