Wed Oct 8 08:48:34 2025 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) 6.791688 6.791688 -173.240494 173.240494 -45.433376 45.433376 -22.506406 22.506406 176.439979 176.439979 0.993759 0.993759 141.681819 141.681819 90.895986 90.895986 -54.400647 54.400647 69.061802 69.061802 79233756 79233756 -77085411 77085411 44337153 44337153 62646956 62646956 69492445 69492445 59485172 59485172 -16124309 16124309 -96434575 96434575 53404370 53404370 -24642397 24642397 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 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 -804 -19 42 -6 457 -11 -42 -5 568 -82 -7 -6 133 78 1 55 217 -29 -8 -15 731 -52 -15 -49 125 -36 -4 -19 734 46 15 44 341 64 5 21 -772 -83 9 -25 -34.408457 2.398013 -15.000000 1.561736 -10.168893 -10.461190 0.000000 -10.168893 72.132434 -1.086882 -67.000000 -0.688693 42.210739 11.654324 3.000000 7.247769 -76.099938 -6.781850 11.000000 -1.499593 -258.090647 -3.681139 70.000000 -0.410943 -189.496878 -10.377216 18.000000 -2.706992 9.398342 -24.774631 -1.000000 -15.376289 54.361608 1.697700 32.000000 0.035209 -137.396262 2.540523 -55.000000 2.332521 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 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 0x7f418a621150>, '__name__': '__main__', '__package__': None, '__spec__': None, 'abs_test': , 'all_test': , 'any_test': , 'bin_test': , 'bool_test': , 'bytearray_test': , 'chr_test': , 'dir_test': , 'divmod_test': , 'eval_test': , 'float_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' -4429236571272856855 ' abcde' -7082727818965239165 ' 12345' 3390150893126404603 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)= 139919473244496 b = 3 id(b)= 139919472197936 c = Hallelujah! id(c)= 139919470333232 d = [1 2 3] id(d)= 139919269280816 e = id_test, id(e) = 139919470172128 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) 190 -923 190 829 -427 829 102 -102 102 822 891 891 -377 -802 -377 147 -44 147 861 -836 861 66 910 910 469 -786 469 883 -136 883 max(a) returns the maximum element of a. a1 a2 a3 max(a) 786 687 -737 786 763 -647 519 763 426 668 330 668 595 -933 -744 595 -911 -957 152 152 -376 -983 -50 -50 437 -829 -158 437 -199 -354 -372 -199 663 804 672 804 -764 -812 28 28 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) -152.55 151.53 -152.55 -74.17 -24.95 -74.17 174.15 96.08 96.08 3.74 14.91 3.74 -188.37 -116.21 -188.37 232.22 -46.95 -46.95 52.67 -31.52 -31.52 104.18 -44.69 -44.69 113.27 -169.94 -169.94 60.96 35.85 35.85 min(a) returns the minimum element of a. a1 a2 a3 min(a) -35.99 28.53 -45.37 -45.37 -235.89 163.56 49.29 -235.89 -153.54 -248.26 18.73 -248.26 -5.34 14.03 -57.14 -57.14 -80.80 28.58 13.21 -80.80 140.81 -1.83 129.44 -1.83 116.83 -42.02 -105.81 -105.81 88.88 -18.60 -173.83 -173.83 199.42 -12.57 109.33 -12.57 -47.85 119.48 -145.20 -145.20 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) -88.561974 -89.000000 58.295973 58.000000 -16.485163 -16.000000 -11.266080 -11.000000 -31.202782 -31.000000 63.638315 64.000000 -153.884746 -154.000000 -221.726081 -222.000000 -111.316199 -111.000000 -271.374857 -271.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. Wed Oct 8 08:48:34 2025