(base) bash-5.2$ date Mon Sep 11 02:42:29 PM EDT 2023 (base) bash-5.2$ pwd /home/accts/sbs5/cs200/www/lectures (base) bash-5.2$ p Python 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> help(len) Help on built-in function len in module builtins: len(obj, /) Return the number of items in a container. >>> len("hello") 5 >>> len([1,2,3]) 3 >>> import collatz >>> dir(collatz) ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'collatz', 'collatzg', 'cseries'] >>> dir(collatz.collatz) ['__annotations__', '__builtins__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__getstate__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] >>> dir(collatz.collatz.__code__) ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_co_code_adaptive', '_varname_from_oparg', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_exceptiontable', 'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars', 'co_kwonlyargcount', 'co_lines', 'co_linetable', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_positions', 'co_posonlyargcount', 'co_qualname', 'co_stacksize', 'co_varnames', 'replace'] >>> x = "Hello World!" >>> x2 = 'Hello World!' >>> x3 = ''' ... Hello ... World! ... ''' >>> x 'Hello World!' >>> x2 'Hello World!' >>> x3 '\nHello\nWorld!\n' >>> print(x3) Hello World! >>> x4 = '"Hwllo World!"' >>> x4 '"Hwllo World!"' >>> x5 = 'I can\'t hear you.' >>> x6 Traceback (most recent call last): File "", line 1, in NameError: name 'x6' is not defined. Did you mean: 'x'? >>> x5 "I can't hear you." >>> x6 = 'price\\earnings' >>> x6 'price\\earnings' >>> print (x6) price\earnings >>> tyoe(x) Traceback (most recent call last): File "", line 1, in NameError: name 'tyoe' is not defined. Did you mean: 'type'? >>> type(x) >>> str(123) '123' >>> len(x) 12 >>> x 'Hello World!' >>> len(x2) 12 >>> len(x3) 14 >>> x3 '\nHello\nWorld!\n' >>> len(x6) 14 >>> dir(str) ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] >>> x 'Hello World!' >>> x.lower() 'hello world!' >>> x 'Hello World!' >>> x.upper() 'HELLO WORLD!' >>> x 'Hello World!' >>> y = x + ' ' >>> y 'Hello World! ' >>> len(y) 15 >>> len(x) 12 >>> y.strip() 'Hello World!' >>> y.strip() C-c C-c KeyboardInterrupt >>> len(y.strip()) 12 >>> y 'Hello World! ' >>> x 'Hello World!' >>> x.isapha() Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'isapha'. Did you mean: 'isalpha'? >>> x.isalpha() False >>> 'hello'.isalpha() True >>> 'hello'.isdigit() False >>> '1234'.isdigit() True >>> ' '.isspace() File "", line 1 ' '.isspace() IndentationError: unexpected indent >>> ' '.isspace() File "", line 1 ' '.isspace() IndentationError: unexpected indent >>> ' '.isspace() True >>> ' \n\t'.isspace() True >>> ' \n\t\f'.isspace() True >>> x 'Hello World!' >>> x.find('W') 6 >>> x 'Hello World!' >>> x.find('q') -1 >>> x 'Hello World!' >>> x[6] 'W' >>> x[-1] '!' >>> x[-3] 'l' >>> len(x) 12 >>> x[12] Traceback (most recent call last): File "", line 1, in IndexError: string index out of range >>> x[11] '!' >>> x[-10] 'l' >>> x[-12] 'H' >>> x[-13] Traceback (most recent call last): File "", line 1, in IndexError: string index out of range >>> x 'Hello World!' >>> x[0:3] 'Hel' >>> x[0:] 'Hello World!' >>> x[:] 'Hello World!' >>> x[:5] 'Hello' >>> x[:8.2] Traceback (most recent call last): File "", line 1, in TypeError: slice indices must be integers or None or have an __index__ method >>> x[:8:2] 'HloW' >>> x[:8:3] 'HlW' >>> x[:8:-1] '!dl' >>> x 'Hello World!' >>> x[::-1] '!dlroW olleH' >>> id(x) 139722965806320 >>> id(x2) 139722962874928 >>> id(x3) 139722965976240 >>> id(x) 139722965806320 >>> xc = x[:] >>> xc 'Hello World!' >>> id(xc) 139722965806320 >>> xc = xc + 'x' >>> xc 'Hello World!x' >>> x 'Hello World!' >>> id(x) 139722965806320 >>> id(xc) 139722963999856 >>> xc = x >>> xc 'Hello World!' >>> id(xc) 139722965806320 >>> x == xc True >>> x is xc True >>> x 'Hello World!' >>> x.replace('l','L') 'HeLLo WorLd!' >>> x 'Hello World!' >>> s = "the swift brown fox jumped over the lazy dog" >>> s 'the swift brown fox jumped over the lazy dog' >>> len(s) 44 >>> s.split() ['the', 'swift', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy', 'dog'] >>> sl = s.split() >>> sl ['the', 'swift', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy', 'dog'] >>> '-'.join(sl) 'the-swift-brown-fox-jumped-over-the-lazy-dog' >>> ' '.join(sl) 'the swift brown fox jumped over the lazy dog' >>> sd = '-'.join(sl) >>> sd 'the-swift-brown-fox-jumped-over-the-lazy-dog' >>> sd.split() ['the-swift-brown-fox-jumped-over-the-lazy-dog'] >>> sd.split('-') ['the', 'swift', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy', 'dog'] >>> odr('A") File "", line 1 odr('A") ^ SyntaxError: unterminated string literal (detected at line 1) >>> ord('A") File "", line 1 ord('A") ^ SyntaxError: unterminated string literal (detected at line 1) >>> ord('A') 65 >>> ord('a') 97 >>> char(97) Traceback (most recent call last): File "", line 1, in NameError: name 'char' is not defined. Did you mean: 'chr'? >>> chr(97) 'a' >>> 0xA 10 >>> oxB Traceback (most recent call last): File "", line 1, in NameError: name 'oxB' is not defined >>> 0xb 11 >>> 0xabc 2748 >>> 0x1a 26 >>> 0x100 256 >>> 0x10a 266 >>> 0x3b4 948 >>> chr(0x3b4) 'δ' >>> chr(0x3b5) 'ε' >>> chr(0x3b1) 'α' >>> chr(0x3b2) 'β' >>> chr(0x3b3) 'γ' >>> l = [1,2,3,4,5] >>> l [1, 2, 3, 4, 5] >>> len(l) 5 >>> l[3] 4 >>> l[-1] 5 >>> l[-3] 3 >>> l[:3] [1, 2, 3] >>> l[2:] [3, 4, 5] >>> l[:] [1, 2, 3, 4, 5] >>> l[::-1] [5, 4, 3, 2, 1] >>> x 'Hello World!' >>> x[0] = 'x' Traceback (most recent call last): File "", line 1, in TypeError: 'str' object does not support item assignment >>> l[0] = 88 >>> l [88, 2, 3, 4, 5] >>> for n in l: ... print (n) ... 88 2 3 4 5 >>> for x in l: ... print (x , ' ', end='') ... 88 2 3 4 5 >>> for x in l: ... print (x, end='.') ... 88.2.3.4.5.>>> sum = 0 >>> for x in l: ... sum = sum + x ... >>> sum 102 >>> for x in l: ... sum += x ... >>> sum 204 >>> l [88, 2, 3, 4, 5] >>> 4 in l True >>> 7 in l False >>> l [88, 2, 3, 4, 5] >>> rl = l[::-1] >>> rl [5, 4, 3, 2, 88] >>> for i,v in enumerate(rl): ... print (i, v) ... 0 5 1 4 2 3 3 2 4 88 >>> a,b,c = 5,6,7 >>> a 5 >>> b 6 >>> c 7 >>> a,b = b,a >>> a 6 >>> b 5 >>> (base) bash-5.2$ exit Process shell finished