def test_label() : try : import human except e: print( e, ";" ) return ages = [ 17, 33, 48, 65, 88 ] for n in ages : try : r = human.label( n ) print( 'label(', n, '):', r ) except e: print( e, ";" ) return def test_flatten() : try : import datable except e: print( e, ";" ) return d1 = [[31, 28, 31, 30], [31, 30, 31, 31], [30, 31, 30, 31 ]] d2 = [[1, 1, 2, 3], [5, 8, 13, 21], [34, 55, 89, 144], [233, 377, 610 ]] try : r = datable.flatten( d1 ) print( 'flatten( d1 ):', r ) r = datable.flatten( d2 ) print( 'flatten( d2 ):', r ) except e: print( e, ";" ) return def test_similar() : try : import datable except e: print( e, ";" ) return a1 = [[31, 28, 31, 30], [31, 30, 31, 31], [30, 31, 30, 31 ]] b1 = [[31, 28, 31, 30, 31, 30, 31, 31, 30], [31, 30, 31 ]] a2 = [[1, 1, 2, 3], [5, 8, 13, 21], [34, 55, 89, 144], [233, 377, 610, 987 ]] b2 = [[1, 2, 3, 4], [5, 8, 13], [34, 55, 89], [233, 377, 610, 987 ]] try : r = datable.similar( a1, b1 ) print( 'similar( a1, b1 ):', r ) r = datable.similar( a2, b2 ) print( 'similar( a2, b2 ):', r ) except e: print( e, ";" ) return def test_sixes() : import random seeds = [ 'abc', 1, 2 ] try : import rolling except e: print( e, ";" ) return for seed in seeds : try : random.seed( seed ) r = rolling.sixes() print( 'sixes():', r ) except e: print( e, ";" ) return def test_count() : try : import valuable except e : print( e, ";" ) d1 = { 3: 1, 4: 1, 5: 9 } d2 = { 'f': 'a', 'c': 'e', 'i': 'o', 'u': 's' } tests = [ (d1, 1), (d1, 2), (d2, 'a'), (d2, 'e') ] try : d, v = tests[ 0 ] r = valuable.count( d, v ) output = 'count( d1, ' + str( v ) + ' ): ' + str( r ) print( output ) d, v = tests[ 1 ] r = valuable.count( d, v ) output = 'count( d1, ' + str( v ) + ' ): ' + str( r ) print( output ) d, v = tests[ 2 ] r = valuable.count( d, v ) output = 'count( d2, "' + v + '" ): ' + str( r ) print( output ) d, v = tests[ 3 ] r = valuable.count( d, v ) output = 'count( d2, "' + v + '" ): ' + str( r ) print( output ) except e : print( e, ";" ) def test_is_unique() : try : import valuable except e : print( e, ";" ) d1 = { 3: 1, 4: 1, 5: 9 } d2 = { 'f': 'a', 'c': 'e', 'i': 'o', 'u': 's' } tests = [ (d1, 1), (d1, 2), (d2, 'a'), (d2, 'e') ] try : r = valuable.is_unique( d1 ) output = 'is_unique( d1 ): ' + str( r ) print( output ) r = valuable.is_unique( d2 ) output = 'is_unique( d2 ): ' + str( r ) print( output ) except e : print( e, ";" ) def test_ding() : x1 = [ 2, 1, 1, 1 ]; x2 = [ 'p', 'i', 'n', 'k', 'y', ] y1 = [ 1, 6, 2, 5, 4 ]; y2 = [ 't', 'o', 'e', ] tests = [ (x1, y1), (x2, y2) ] try : import wed except e : print( e, ';' ) return n = len( tests ) for i in range( 0, n ) : x, y = tests[ i ] try : z = wed.ding( x, y ) output = 'ding( x' + str(i+1) + ', y' + str(i+1) + ' ): ' + str( z ) print( output ) except e: print( e, ";" ) def test_factorial() : tests = [ 5, 6, 10 ] try : import determine except e : print( e, ';' ) return for n in tests : try : f = determine.factorial( n ) output = str(n) + '!: ' + str( f ) print( output ) except e : print( e, ';' ) return def test_combinations() : tests = [ (5, 2), (6, 4), (10, 6) ] try : import determine except e : print( e, ';' ) return for test in tests : n, k = test try : r = determine.combinations( n, k ) print( 'combinations(', n, ',', k, '):', r ) except e : print( e, ';' ) return def test_composed() : tests = [ ( "arst", "rat" ), ( "arst", "strata"), ( "cab", "bad" ) ] try : import look except e : print( e, ';' ) return for test in tests : letters, word = test try : r = look.composed( letters, word ) output = 'composed( "' + letters + '", ' + '"' + word + '" ): ' + str( r ) print( output ) except e : print( e, ';' ) return def test_which() : strings = [ "bc", "cc", "bab", "cad", "bit", "cab" ] tests = [ ( "abct", strings ) ] try : import look except e : print( e, ';' ) return for test in tests : letters, words = test try : r = look.which( letters, words ) output = 'which( "' + letters + '", strings ): ' + str( r ) print( output ) except e : print( e, ';' ) return def test_pair() : try : import euclid except e: print( e, ";" ) return tests = [ [ (9,4), (6,1) ], [ (3,5), (7,5) ], [ (7,2), (9,2) ], ] for test in tests : p1, p2 = test try : r = euclid.pair( p1, p2 ) output = 'pair( ' + str(p1) + ', ' + str(p2) + ' ): ' + str( r ) print( output ) except e: print( e, ';' ) return def test_series() : try : import euclid except e: print( e, ";" ) return tests = [ [ (9,4), (6,1), (3,5), (7,5), (7,2), (9,2) ] ] for test in tests : pts = test try : r = euclid.series( pts ) output = 'series( ' + str(pts) + ' ): ' + str( r ) print( output ) except e: print( e, ';' ) return def test_perimeter() : try : import euclid except e: print( e, ";" ) return tests = [ [ (9,4), (6,1), (3,5), (7,5), (7,2), (9,2) ] ] for test in tests : pts = test try : r = euclid.perimeter( pts ) output = 'perimeter( ' + str(pts) + ' ): ' + str( r ) print( output ) except e: print( e, ';' ) return def test_max_rgb() : tests = [ (80,75,70), (80,95,70), (80,75,99) ] try : import pixie except e : print( e, ';' ) return for i in range( 0, 3) : pixel = tests[ i] try : r = pixie.max_rgb( pixel ) output = 'max_rgb( p' + str(i+1) + ' ): ' + str( r ) print( output ) except e : print( e, ';' ) def test_tricolor() : from PIL import Image try : import pixie except e : print( e, ';' ) return w, h = 600, 300 img = Image.new( "RGB", (w, h) ) import random random.seed( 1112 ) for x in range(0, w) : for y in range(0, h) : r = random.randrange( 0, 225 ) g = random.randrange( 0, 225 ) b = random.randrange( 0, 225 ) if ( x < w / 3 ) : r = max( (r,g,b) ) + 10 elif ( x < 2 * w / 3 ) : g = max( (r,g,b) ) + 10 else : b = max( (r,g,b) ) + 10 img.putpixel( (x,y), (r,g,b) ) try : r = pixie.tricolor( img ) except: print( "blowsup" ) return r.show()