Mon Jan 5 10:38:17 2026 python_intrinsics_test(): python version: 3.10.12 numpy version: 1.26.4 Test python_intrinsics(). abs_test(): abs() returns the absolute value of a number. x abs(x) 104.885471 104.885471 -228.997494 228.997494 95.826576 95.826576 -6.499524 6.499524 117.872991 117.872991 161.262125 161.262125 64.003300 64.003300 -95.941958 95.941958 -44.380176 44.380176 43.787818 43.787818 -51091992 51091992 94318323 94318323 54406125 54406125 11382124 11382124 -54502605 54502605 37925483 37925483 -67824851 67824851 28577649 28577649 62232530 62232530 70933147 70933147 all_test(): all() returns True if all elements are True. a = [ -2 , 4 , 12 ] all(a<10) False all(a!=0) True (all(-5? @ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]^_ `abcdefghijklmno pqrstuvwxyz{|}~X ceil_test(): ceil(x) returns the smallest integer greater than or equal to x. x = 12.34 , ceil(x)= 13 x = -12.34 , ceil(x)= -12 x = 12.0 , ceil(x)= 12 x = -12.0 , ceil(x)= -12 complex_test(): complex(x,y) converts two real numbers into one complex value. x = 12.3 y = 45.6 complex(x,y) = (12.3+45.6j) dir_test(): dir() lists objects. dir(x) lists methods and properties of object x The dir() command actually only prints information during interactive use, so the following dir() commands will not print out anything, since we are running noninteractively. After defining a, b, c, and d, issue "dir()" ['a', 'b', 'c', 'd', 'pprint', 'string'] Issue "dir(b)" ['__abs__', '__add__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getformat__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__le__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__pos__', '__pow__', '__radd__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rmod__', '__rmul__', '__round__', '__rpow__', '__rsub__', '__rtruediv__', '__setattr__', '__setformat__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', 'as_integer_ratio', 'conjugate', 'fromhex', 'hex', 'imag', 'is_integer', 'real'] divmod_test(): divmod(a,b) returns the rounded quotient and remainder of a/b. a b q r 361 -25 -15 -14 -301 79 -4 15 -241 -41 5 -36 859 78 11 1 921 -43 -22 -25 -881 22 -41 21 820 -5 -164 0 225 -54 -5 -45 148 -7 -22 -6 -750 -4 187 -2 84.975821 6.979224 12.000000 1.225136 52.651301 -8.876557 -6.000000 -0.608043 6.077765 3.800608 1.000000 2.277157 -26.407772 -5.424352 4.000000 -4.710364 -30.991723 5.322288 -6.000000 0.942008 -3.747355 -10.391389 0.000000 -3.747355 14.104774 -3.652480 -4.000000 -0.505146 77.784890 2.733023 28.000000 1.260258 -80.598531 -1.573699 51.000000 -0.339906 13.951296 19.946803 0.000000 13.951296 eval_test(): eval() takes a string, which might represent a formula, and evaluates it. x = 1 s = ' x + 9 ', eval(s) = 10 x = 101 s = ' x + 9 ', eval(s) = 110 a = 1.2 b = 8.0 s = ' a * b + 1 ', eval(s) = 10.6 float_test(): float() returns the float version of a value. a = 123456 , float(a)= 123456.0 a = 3.141592653589793 , float(a)= 3.141592653589793 a = ' 123.456 ', float(a)= 123.456 floor_test(): floor(x) returns the largest integer no bigger than x. x = 12.34 , floor(x)= 12 x = -12.34 , floor(x)= -13 x = 12.0 , floor(x)= 12 x = -12.0 , floor(x)= -12 globals_test(): globals() lists the global variables. {'__annotations__': {}, '__builtins__': , '__cached__': None, '__doc__': None, '__file__': '/home/john/public_html/py_src/python_intrinsics_test/python_intrinsics_test.py', '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x701f91d25150>, '__name__': '__main__', '__package__': None, '__spec__': None, 'abs_test': , 'all_test': , 'any_test': , 'bin_test': , 'bool_test': , 'bytearray_test': , 'ceil_test': , 'chr_test': , 'complex_test': , 'dir_test': , 'divmod_test': , 'eval_test': , 'float_test': , 'floor_test': , 'globals_test': , 'hash_test': , 'hex_test': , 'id_test': , 'int_test': , 'len_test': , 'locals_test': , 'max_test': , 'min_test': , 'oct_test': , 'ord_test': , 'pow_test': , 'python_intrinsics_test': , 'range_test': , 'reversed_test': , 'round_test': , 'slice_test': , 'sorted_test': , 'sum_test': , 'timestamp': } hash_test(): hash() returns a hash value. x hash(x) -1 -2 -2 -2 -3 -3 0 0 1 1 2 2 12345 12345 2019 2019 -11 -11 691752902764109836 691752902764109836 0 0 1 1 3.14159265359 326490430436040707 12345.6789 1565436818957021241 ' a' -2447309289932949986 ' abcde' -824563672072476126 ' 12345' 5379729989208234689 hex_test(): hex() returns a string that is the hexadecimal representation of an integer. i hex(i) 0 0x0 1 0x1 2 0x2 3 0x3 4 0x4 5 0x5 10 0xa 20 0x14 30 0x1e 2019 0x7e3 -11 -0xb id_test(): id() returns the unique identifing number of an object. a = 3.141592653589793 id(a)= 123280892640624 b = 3 id(b)= 123280903160112 c = Hallelujah! id(c)= 123280891827952 d = [1 2 3] id(d)= 123280724311760 e = id_test, id(e) = 123280891664784 int_test(): int() returns the integer version of a value. You cannot convert a complex value. You cannot convert a string which includes a decimal point. a = 3.141592653589793 , int(a)= 3 a = 4.5 , int(a)= 4 a = 5.5 , int(a)= 5 a = ' 904 ', int(a)= 904 a = ' 101 ', int(a,2)= 5 a = ' 101 ', int(a,5)= 26 a = ' 101 ', int(a,10)= 101 a = ' 101 ', int(a,16)= 257 len_test(): len() returns the length of a string, tuple, or list. x=range(5,10) len(x) = 5 x='Matlab' len(x) = 6 x = [ 10, 11, 12 ] len(x) = 3 x = ( 10, 11, 12 ) len(x) = 3 locals_test(): locals() lists the local variables. {'a': 1, 'b': 2.3, 'c': 'Who is that?', 'data': array([-1, -2, -3]), 'e': (4, 5, 6), 'np': , 'pprint': } max_test(): max() returns the maximum of a pair of arguments, or an array. max(a,b) returns the maximum of a and b. a b max(a,b) 231 957 957 112 173 173 -555 57 57 210 -192 210 677 -137 677 313 -953 313 -520 560 560 553 -58 553 -986 -548 -548 299 -276 299 max(a) returns the maximum element of a. a1 a2 a3 max(a) -406 363 -611 363 -112 -671 -191 -112 191 272 -253 272 734 721 -971 734 -635 879 -917 879 979 879 -927 979 322 211 901 901 164 -18 -408 164 639 -585 556 639 -766 -932 616 616 min_test(): min() returns the minimum of a pair of arguments, or an array. min(a,b) returns the minimum of a and b. a b min(a,b) 26.63 -26.24 -26.24 107.82 -177.88 -177.88 64.08 -28.50 -28.50 -68.90 76.72 -68.90 -50.75 -236.22 -236.22 126.91 -61.11 -61.11 154.17 -83.98 -83.98 62.00 -16.53 -16.53 -63.74 82.02 -63.74 -64.54 -144.25 -144.25 min(a) returns the minimum element of a. a1 a2 a3 min(a) 21.88 37.45 -62.00 -62.00 22.05 41.67 20.70 20.70 -124.62 -58.13 -80.94 -124.62 143.71 201.13 78.41 78.41 83.17 83.56 105.40 83.17 -49.22 65.63 201.40 -49.22 97.55 92.93 112.42 92.93 67.87 80.21 27.37 27.37 -45.13 -8.80 39.43 -45.13 -84.65 -53.73 -54.87 -84.65 oct_test(): oct() returns a string that is the octal representation of an integer. i oct(i) 0 0o0 1 0o1 2 0o2 3 0o3 4 0o4 5 0o5 10 0o12 20 0o24 30 0o36 2019 0o3743 -11 -0o13 ord_test(): ord(c) returns the index of character c. String of characters: " Isn't this wonderful? ". ' I ' has character index 73 ' s ' has character index 115 ' n ' has character index 110 ' ' ' has character index 39 ' t ' has character index 116 ' ' has character index 32 ' t ' has character index 116 ' h ' has character index 104 ' i ' has character index 105 ' s ' has character index 115 ' ' has character index 32 ' w ' has character index 119 ' o ' has character index 111 ' n ' has character index 110 ' d ' has character index 100 ' e ' has character index 101 ' r ' has character index 114 ' f ' has character index 102 ' u ' has character index 117 ' l ' has character index 108 ' ? ' has character index 63 pow_test(): pow(a,b) returns a to the power b. a b pow(a,b) 2 3 8 2 -3 0.125 -2 3 -8 -2 -3 -0.125 3.14159 3 31.0063 3.14159 -3 0.0322515 2 3.14159 8.82498 pow(a,b,z) returns a to the power b, mod z. a b c pow(a,b,z) 10 3 3 1 10 3 5 0 10 3 7 6 range_test(): range(a,b) creates a range of integers from a to b-1. range(a,b,c) creates a range of integers from a to b-1 by increments of c. x=range(5,10) range(5, 10) 5,6,7,8,9, x=range(1,11,2) range(1, 11, 2) 1,3,5,7,9, x=range(11,1,-2) range(11, 1, -2) 11,9,7,5,3, x=range(10,20) = range(10, 20) y = (8 in x) is False len(x) = 10 reversed_test(): reversed(object) returns a "reversed" version of the object. x=range(5,10) 5 6 7 8 9 xr = reversed(x) 9 8 7 6 5 s='Matlab' M a t l a b sr = reversed(s) b a l t a M x = [ 10, 11, 12 ] 10 11 12 xr = reversed(x) 12 11 10 x = ( 10, 11, 12 ) 10 11 12 xr = reversed(x) 12 11 10 round_test(): round(x) rounds x to the nearest integral value. x round(x) -176.725953 -177.000000 170.230693 170.000000 -18.097695 -18.000000 195.909194 196.000000 -23.206272 -23.000000 86.339284 86.000000 64.269760 64.000000 -132.303579 -132.000000 -107.749977 -108.000000 158.431081 158.000000 round(x,ndigits) rounds x to n digits. x ndigits round(x,ndigits) 314.1592653590 0 314.0000000000 314.1592653590 1 314.2000000000 314.1592653590 2 314.1600000000 314.1592653590 3 314.1590000000 314.1592653590 4 314.1593000000 314.1592653590 5 314.1592700000 314.1592653590 6 314.1592650000 314.1592653590 7 314.1592654000 314.1592653590 8 314.1592653600 314.1592653590 9 314.1592653590 314.1592653590 10 314.1592653590 slice_test(): slice() creates an object represented by range(start:stop:increment) s: ' Abcdefghijklmnopqrstuvwxyz ' s[slice(0,10,2)]: Acegi s[slice(26,0,-3)]: zwtqnkheb s[slice(6)]: Abcdef sorted_test(): sorted(x) returns a sorted list x = [3, 1, 4, 6, 2] sorted(x) =( [1, 2, 3, 4, 6] sorted(x,reverse=True) =( [6, 4, 3, 2, 1] x = [1.23, 231.0, 31.2, 0.35] sorted(x) =( [0.35, 1.23, 31.2, 231.0] sorted(x,reverse=True) =( [231.0, 31.2, 1.23, 0.35] x = ['a', 'c', 'z', 'b', 'D'] sorted(x) =( ['D', 'a', 'b', 'c', 'z'] sorted(x,reverse=True) =( ['z', 'c', 'b', 'a', 'D'] x = Anaconda sorted(x) =( ['A', 'a', 'a', 'c', 'd', 'n', 'n', 'o'] sorted(x,reverse=True) =( ['o', 'n', 'n', 'd', 'c', 'a', 'a', 'A'] sum_test(): sum(x) computes the sum of entries sum( [5.0, 10.1, 15.2, 20.3] ) = 50.599999999999994 sum(x) can count Boolean True values sum( [False, True, True, False] ) = 2 sum(x,init) computes the sum of the entries plus init. sum( [5.0, 10.1, 15.2, 20.3] ,100) = 150.6 python_intrinsics_test: Normal end of execution. Mon Jan 5 10:38:17 2026