sbs5@tiger:~/cs200/www/lectures$ date Wed Jan 28 01:08:55 PM EST 2026 sbs5@tiger:~/cs200/www/lectures$ pwd /home/accts/sbs5/cs200/www/lectures sbs5@tiger:~/cs200/www/lectures$ ls my* mycalendar.py mydb.db mydbtest.db sbs5@tiger:~/cs200/www/lectures$ chmod 775 mycalendar.py sbs5@tiger:~/cs200/www/lectures$ ./mycalendar.py Calendar Program Enter year: 2026 Enter month: 1 Here is the calendar: January 2026 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 sbs5@tiger:~/cs200/www/lectures$ p Python 3.12.3 (main, Jan 8 2026, 11:30:50) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def rtoord(str): if not str: return else: c = str[0] print (c, " => ", ord(c)) rtoord(str[1:]) ... ... ... ... ... ... ... >>> rtoord('abcABC') a => 97 b => 98 c => 99 A => 65 B => 66 C => 67 >>> def trace2(f): f.indent = 0 def g(*x): print('| ' * f.indent + '|--', f.__name__, x) f.indent += 1 value = f(*x) print('| ' * f.indent + '|--', 'return', repr(value)) f.indent -= 1 return value return g ... ... ... ... ... ... ... ... ... ... >>> rtoord = trace2(roord) Traceback (most recent call last): File "", line 1, in NameError: name 'roord' is not defined. Did you mean: 'rtoord'? >>> rtoord = trace2(rtoord) >>> rtoord('abcABC') |-- rtoord ('abcABC',) a => 97 | |-- rtoord ('bcABC',) b => 98 | | |-- rtoord ('cABC',) c => 99 | | | |-- rtoord ('ABC',) A => 65 | | | | |-- rtoord ('BC',) B => 66 | | | | | |-- rtoord ('C',) C => 67 | | | | | | |-- rtoord ('',) | | | | | | | |-- return None | | | | | | |-- return None | | | | | |-- return None | | | | |-- return None | | | |-- return None | | |-- return None | |-- return None >>> from listcomp import * >>> a = [] for n in str(12345): a.append(n) >>> ... ... >>> a ['1', '2', '3', '4', '5'] >>> map(lambda x: x, "12345") >>> m = map(lambda x: x, "12345") >>> next(m) '1' >>> next(m) '2' >>> next(m) '3' >>> m = list(map(lambda x: x, "12345")) >>> m ['1', '2', '3', '4', '5'] >>> a1 ['1', '2', '3', '4', '5'] >>> [x for x in str(12345)] ['1', '2', '3', '4', '5'] >>> a == a1 == a2 True >>> b [1, 2, 3, 4, 5] >>> b1 [1, 2, 3, 4, 5] >>> b2 [1, 2, 3, 4, 5] >>> b == b1 == b2 True >>> c [1, 4, 9, 16, 25] >>> c1 [1, 4, 9, 16, 25] >>> c2 [1, 4, 9, 16, 25] >>> c == c1 == c2 True >>> d [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16)] >>> d1 [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16)] >>> d1a [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16)] >>> d2 [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16)] >>> d == d1 == d2 True >>> ee2 [(0, 5), (1, 4), (2, 3), (3, 2), (4, 1)] >>> e [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e')] >>> [(x[0],x[1]) for x in enumerate("abcde")] [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e')] >>> f [0, 2, 4, 6, 8] >>> f1 [0, 2, 4, 6, 8] >>> f2 [0, 2, 4, 6, 8] >>> f == f1 == f2 True >>> g [5, 6, 7, 8, 9] >>> g1 [5, 6, 7, 8, 9] >>> g2 [5, 6, 7, 8, 9] >>> g == g1 == g2 True >>> l Traceback (most recent call last): File "", line 1, in NameError: name 'l' is not defined >>> l = ['morse', 'stiles', '', 'franklin', 'edwards','', "", '', 'branford', '', 'trumbull', '', '', 'hopper'] l >>> ['morse', 'stiles', '', 'franklin', 'edwards', '', '', '', 'branford', '', 'trumbull', '', '', 'hopper'] >>> l ['morse', 'stiles', '', 'franklin', 'edwards', '', '', '', 'branford', '', 'trumbull', '', '', 'hopper'] >>> list(filter(None, l)) ['morse', 'stiles', 'franklin', 'edwards', 'branford', 'trumbull', 'hopper'] >>> [x for x in l if x] ['morse', 'stiles', 'franklin', 'edwards', 'branford', 'trumbull', 'hopper'] >>> noprimes [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98] >>> len(noprimes) 149 >>> set(noprimes) {4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99} >>> len(set(noprimes)) 73 >>> primes >>> xxprimes = [x for x in range(2, 100) if x not in noprimes] >>> xxprimes [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] >>> len(xxprimes) 25 >>> s1 [1, 1, 3, 3, 5, 5, 7, 7, 9, 9] >>> s2 = {x if x % 2 else x + 1 for x in range(10)} >>> s2 {1, 3, 5, 7, 9} >>> set(s1) {1, 3, 5, 7, 9} >>> s2 {1, 3, 5, 7, 9} >>> len(s2) 5 >>> s2[2] Traceback (most recent call last): File "", line 1, in TypeError: 'set' object is not subscriptable >>> s2.append(8) Traceback (most recent call last): File "", line 1, in AttributeError: 'set' object has no attribute 'append' >>> type(s2) >>> type(s1) >>> s3 = {1,2,3,4} >>> s3 {1, 2, 3, 4} >>> type(s3) >>> s3 = {1,2,3,4,4,4,4} >>> s3 {1, 2, 3, 4} >>> d = {} >>> d['a'] - 1 Traceback (most recent call last): File "", line 1, in KeyError: 'a' >>> d['a'] = 65 >>> d['b'] = 66 >>> ord('a') 97 >>> d['a'] = 97 >>> d['b'] = 98 >>> d {'a': 97, 'b': 98} >>> d['a'] 97 >>> d = {i : x*x for (i,x) in enumerate(range(10))} >>> d[5] 25 >>> sbs5@tiger:~/cs200/www/lectures$ cd /c/cs2000/hws sbs5@tiger:/c/cs2000/hws$ ls hw0a.pyc hw1a.pyc hw2a.pyc __pycache__ hw0.py hw1.py hw2.py sbs5@tiger:/c/cs2000/hws$ p Python 3.12.3 (main, Jan 8 2026, 11:30:50) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from hw1a import * >>> main() hours # is it greater than 0? X got: 0 expected: . at 0x7b6f7e5cb2e0> sum_digits OK got: 1 expected: 1 OK got: 4 expected: 4 OK got: 1 expected: 1 OK got: 45 expected: 45 OK got: 9 expected: 9 reduce OK got: 9 expected: 9 OK got: 9 expected: 9 OK got: 5 expected: 5 OK got: 5 expected: 5 largest_digit OK got: 5 expected: 5 OK got: 1 expected: 1 OK got: 5 expected: 5 OK got: 9 expected: 9 inflate OK got: [2, 3, 4] expected: [2, 3, 4] OK got: [2] expected: [2] OK got: [] expected: [] OK got: ['a', 'b', 'c', 3, 4, 5] expected: ['a', 'b', 'c', 3, 4, 5] OK got: [[1], [2], [3]] expected: [[1], [2], [3]] OK got: [3, 4, 5] expected: [3, 4, 5] OK got: [1, 2, 3] expected: [1, 2, 3] OK got: [0, 1, 2] expected: [0, 1, 2] OK got: [101, 102, 103] expected: [101, 102, 103] OK got: ['a', 'b', 'c', 7, 8, 9] expected: ['a', 'b', 'c', 7, 8, 9] OK got: [3.1, 4.2, (5+3j)] expected: [3.1, 4.2, (5+3j)] OK got: [3.6, 4.7, (5.5+3j)] expected: [3.6, 4.7, (5.5+3j)] OK got: [(3.1+5j), (4.2+5j), (5+8j)] expected: [(3.1+5j), (4.2+5j), (5+8j)] lcinflate OK got: [2, 3, 4] expected: [2, 3, 4] OK got: [2] expected: [2] OK got: [] expected: [] OK got: ['a', 'b', 'c', 3, 4, 5] expected: ['a', 'b', 'c', 3, 4, 5] OK got: [[1], [2], [3]] expected: [[1], [2], [3]] OK got: [3, 4, 5] expected: [3, 4, 5] OK got: [1, 2, 3] expected: [1, 2, 3] OK got: [0, 1, 2] expected: [0, 1, 2] OK got: [101, 102, 103] expected: [101, 102, 103] OK got: ['a', 'b', 'c', 7, 8, 9] expected: ['a', 'b', 'c', 7, 8, 9] OK got: [3.1, 4.2, (5+3j)] expected: [3.1, 4.2, (5+3j)] OK got: [3.6, 4.7, (5.5+3j)] expected: [3.6, 4.7, (5.5+3j)] OK got: [(3.1+5j), (4.2+5j), (5+8j)] expected: [(3.1+5j), (4.2+5j), (5+8j)] removep OK got: [1, 3, 5] expected: [1, 3, 5] OK got: [0, 2, 4, 6] expected: [0, 2, 4, 6] OK got: [0, 1, 2, 3] expected: [0, 1, 2, 3] OK got: [3, 4, 5, 6] expected: [3, 4, 5, 6] lcremovep OK got: [1, 3, 5] expected: [1, 3, 5] OK got: [0, 2, 4, 6] expected: [0, 2, 4, 6] OK got: [0, 1, 2, 3] expected: [0, 1, 2, 3] OK got: [3, 4, 5, 6] expected: [3, 4, 5, 6] evenout OK got: [2, 2, 4, 4] expected: [2, 2, 4, 4] OK got: ['a', 'b', 'c'] expected: ['a', 'b', 'c'] OK got: [2, [2], [3], [4]] expected: [2, [2], [3], [4]] OK got: [] expected: [] OK got: ['hello', 'world'] expected: ['hello', 'world'] lcevenout OK got: [2, 2, 4, 4] expected: [2, 2, 4, 4] OK got: ['a', 'b', 'c'] expected: ['a', 'b', 'c'] OK got: [2, [2], [3], [4]] expected: [2, [2], [3], [4]] OK got: [] expected: [] OK got: ['hello', 'world'] expected: ['hello', 'world'] double_factor OK got: [1, 4, 3, 8, 5, 12] expected: [1, 4, 3, 8, 5, 12] OK got: [1, 2, 6, 4, 5, 12] expected: [1, 2, 6, 4, 5, 12] OK got: [] expected: [] OK got: [1, 2, 3, 4, 5, 6] expected: [1, 2, 3, 4, 5, 6] OK got: [-1, -4, -3, -8, -5, -12] expected: [-1, -4, -3, -8, -5, -12] lcdouble_factor OK got: [1, 4, 3, 8, 5, 12] expected: [1, 4, 3, 8, 5, 12] OK got: [1, 2, 6, 4, 5, 12] expected: [1, 2, 6, 4, 5, 12] OK got: [] expected: [] OK got: [1, 2, 3, 4, 5, 6] expected: [1, 2, 3, 4, 5, 6] OK got: [-1, -4, -3, -8, -5, -12] expected: [-1, -4, -3, -8, -5, -12] primes OK got: [2, 3, 5, 7, 11, 13, 17, 19] expected: [2, 3, 5, 7, 11, 13, 17, 19] OK got: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] expected: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] prime_factors OK got: [2, 2, 5] expected: [2, 2, 5] OK got: [2, 2, 2, 2, 2] expected: [2, 2, 2, 2, 2] OK got: [97] expected: [97] OK got: [2, 2, 2, 5, 5, 5] expected: [2, 2, 2, 5, 5, 5] OK got: [2, 3, 5, 7, 11, 13] expected: [2, 3, 5, 7, 11, 13] power_set OK got: [[]] expected: [[]] OK got: [[], [1]] expected: [[], [1]] OK got: [[], [1], [1, 2], [2]] expected: [[], [1], [1, 2], [2]] OK got: [[], [1], [1, 2], [1, 2, 3], [1, 3], [2], [2, 3], [3]] expected: [[], [1], [1, 2], [1, 2, 3], [1, 3], [2], [2, 3], [3]] OK got: [[], [1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 4], [1, 3], [1, 3, 4], [1, 4], [2], [2, 3], [2, 3, 4], [2, 4], [3], [3, 4], [4]] expected: [[], [1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 4], [1, 3], [1, 3, 4], [1, 4], [2], [2, 3], [2, 3, 4], [2, 4], [3], [3, 4], [4]] OK got: [[], [2], [2], [2, 2]] expected: [[], [2], [2], [2, 2]] OK got: [[], ['bacon'], ['bacon', 'mushroom'], ['bacon', 'sausage'], ['bacon', 'sausage', 'mushroom'], ['mushroom'], ['onion'], ['onion', 'bacon'], ['onion', 'bacon', 'mushroom'], ['onion', 'bacon', 'sausage'], ['onion', 'bacon', 'sausage', 'mushroom'], ['onion', 'mushroom'], ['onion', 'peppers'], ['onion', 'peppers', 'bacon'], ['onion', 'peppers', 'bacon', 'mushroom'], ['onion', 'peppers', 'bacon', 'sausage'], ['onion', 'peppers', 'bacon', 'sausage', 'mushroom'], ['onion', 'peppers', 'mushroom'], ['onion', 'peppers', 'sausage'], ['onion', 'peppers', 'sausage', 'mushroom'], ['onion', 'sausage'], ['onion', 'sausage', 'mushroom'], ['peppers'], ['peppers', 'bacon'], ['peppers', 'bacon', 'mushroom'], ['peppers', 'bacon', 'sausage'], ['peppers', 'bacon', 'sausage', 'mushroom'], ['peppers', 'mushroom'], ['peppers', 'sausage'], ['peppers', 'sausage', 'mushroom'], ['sausage'], ['sausage', 'mushroom']] expected: [[], ['bacon'], ['bacon', 'mushroom'], ['bacon', 'sausage'], ['bacon', 'sausage', 'mushroom'], ['mushroom'], ['onion'], ['onion', 'bacon'], ['onion', 'bacon', 'mushroom'], ['onion', 'bacon', 'sausage'], ['onion', 'bacon', 'sausage', 'mushroom'], ['onion', 'mushroom'], ['onion', 'peppers'], ['onion', 'peppers', 'bacon'], ['onion', 'peppers', 'bacon', 'mushroom'], ['onion', 'peppers', 'bacon', 'sausage'], ['onion', 'peppers', 'bacon', 'sausage', 'mushroom'], ['onion', 'peppers', 'mushroom'], ['onion', 'peppers', 'sausage'], ['onion', 'peppers', 'sausage', 'mushroom'], ['onion', 'sausage'], ['onion', 'sausage', 'mushroom'], ['peppers'], ['peppers', 'bacon'], ['peppers', 'bacon', 'mushroom'], ['peppers', 'bacon', 'sausage'], ['peppers', 'bacon', 'sausage', 'mushroom'], ['peppers', 'mushroom'], ['peppers', 'sausage'], ['peppers', 'sausage', 'mushroom'], ['sausage'], ['sausage', 'mushroom']] all_factors OK got: [1, 2, 4, 5, 10, 20] expected: [1, 2, 4, 5, 10, 20] OK got: [1, 2, 4, 8, 16, 32] expected: [1, 2, 4, 8, 16, 32] OK got: [1, 97] expected: [1, 97] OK got: [1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 1000] expected: [1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500, 1000] OK got: [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 21, 22, 26, 30, 33, 35, 39, 42, 55, 65, 66, 70, 77, 78, 91, 105, 110, 130, 143, 154, 165, 182, 195, 210, 231, 273, 286, 330, 385, 390, 429, 455, 462, 546, 715, 770, 858, 910, 1001, 1155, 1365, 1430, 2002, 2145, 2310, 2730, 3003, 4290, 5005, 6006, 10010, 15015, 30030] expected: [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 21, 22, 26, 30, 33, 35, 39, 42, 55, 65, 66, 70, 77, 78, 91, 105, 110, 130, 143, 154, 165, 182, 195, 210, 231, 273, 286, 330, 385, 390, 429, 455, 462, 546, 715, 770, 858, 910, 1001, 1155, 1365, 1430, 2002, 2145, 2310, 2730, 3003, 4290, 5005, 6006, 10010, 15015, 30030] >>> inflate([1,2,3,4]) [2, 3, 4, 5] >>> inflate([1,2,3,4],2) [3, 4, 5, 6] >>> inflate([1,2,3,4],-100) [-99, -98, -97, -96] >>> lcinflate([1,2,3,4],-100) [-99, -98, -97, -96] >>> power_set([1,2]) [[], [1], [1, 2], [2]] >>> power_set([1,2,3]) [[], [1], [1, 2], [1, 2, 3], [1, 3], [2], [2, 3], [3]] >>> power_set([1]) [[], [1]] >>> power_set([1,2]) [[], [1], [1, 2], [2]] >>> toppings Traceback (most recent call last): File "", line 1, in NameError: name 'toppings' is not defined >>> toppings = ['onion','peppers','bacon','sausage','mushroom'] >>> >>> toppings ['onion', 'peppers', 'bacon', 'sausage', 'mushroom'] >>> power_set(toppings) [[], ['bacon'], ['bacon', 'mushroom'], ['bacon', 'sausage'], ['bacon', 'sausage', 'mushroom'], ['mushroom'], ['onion'], ['onion', 'bacon'], ['onion', 'bacon', 'mushroom'], ['onion', 'bacon', 'sausage'], ['onion', 'bacon', 'sausage', 'mushroom'], ['onion', 'mushroom'], ['onion', 'peppers'], ['onion', 'peppers', 'bacon'], ['onion', 'peppers', 'bacon', 'mushroom'], ['onion', 'peppers', 'bacon', 'sausage'], ['onion', 'peppers', 'bacon', 'sausage', 'mushroom'], ['onion', 'peppers', 'mushroom'], ['onion', 'peppers', 'sausage'], ['onion', 'peppers', 'sausage', 'mushroom'], ['onion', 'sausage'], ['onion', 'sausage', 'mushroom'], ['peppers'], ['peppers', 'bacon'], ['peppers', 'bacon', 'mushroom'], ['peppers', 'bacon', 'sausage'], ['peppers', 'bacon', 'sausage', 'mushroom'], ['peppers', 'mushroom'], ['peppers', 'sausage'], ['peppers', 'sausage', 'mushroom'], ['sausage'], ['sausage', 'mushroom']] >>> len(power_set(toppings)) 32 >>> sbs5@tiger:/c/cs2000/hws$ exit Process shell finished