Last login: Wed Feb 10 11:45:17 on ttys002 The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050. (base) MAC:Wed Feb 10:14:09:~> python Python 3.8.5 (default, Sep 4 2020, 02:22:02) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> True or True True >>> True or False True >>> False or True True >>> False or False False >>> not False True >>> not True False >>> True and True True >>> True and False False >>> False and True False >>> False and False False >>> x = [] >>> x.append("cow") >>> x ['cow'] >>> x.append("sheep") >>> x ['cow', 'sheep'] >>> s = "werrewtwer" >>> len(s) 10 >>> len(x) 2 >>> y = ["farmer", "tractor"] >>> x ['cow', 'sheep'] >>> y ['farmer', 'tractor'] >>> x + y ['cow', 'sheep', 'farmer', 'tractor'] >>> x ['cow', 'sheep'] >>> y ['farmer', 'tractor'] >>> id(x) 140581055586880 >>> x += y >>> id(x) 140581055586880 >>> x ['cow', 'sheep', 'farmer', 'tractor'] >>> a = "some" >>> id(a) 140581055765232 >>> a += "thing" >>> a 'something' >>> id(a) 140581055765104 >>> quack = ["teal", "mallard", "canvasback"] >>> squawk = quack >>> id(quack) 140581055763904 >>> id(squawk) 140581055763904 >>> squawk.append("weasel") >>> quack ['teal', 'mallard', 'canvasback', 'weasel'] >>> squawk ['teal', 'mallard', 'canvasback', 'weasel'] >>> squawk is quack True >>> id(0) 4463503680 >>> id(1) - id(0) 32 >>> id(100) - id(0) 3200 >>> id(200) - id(0) 6400 >>> id(250) - id(0) 8000 >>> id(260) - id(0) 140576592119984 >>> id(255) - id(0) 8160 >>> id(256) - id(0) 8192 >>> id(257) - id(0) 140576592119984 >>> id(True) 4463282616 >>> id(False) 4463283352 >>> 616-352 264 >>> dir() ['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'a', 'quack', 's', 'squawk', 'x', 'y'] >>> x ['cow', 'sheep', 'farmer', 'tractor'] >>> y ['farmer', 'tractor'] >>> party = [] >>> party.append(5) >>> party [5] >>> party.append("cowabunga") >>> party [5, 'cowabunga'] >>> party.append([1,2,3,4,5]) >>> party [5, 'cowabunga', [1, 2, 3, 4, 5]] >>> len(party) 3 >>> party[0] 5 >>> party[2] [1, 2, 3, 4, 5] >>> party[2][4] 5 >>> #list is a mutable heterogeneious sequence type >>> >>> nest = [1,[2,3,4,"cows",[5,6,"heifers"]]] >>> nest[1] [2, 3, 4, 'cows', [5, 6, 'heifers']] >>> nest[1][4] [5, 6, 'heifers'] >>> nest[1][4][3] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range >>> nest[1][4][2] 'heifers' >>> nest[1][4][2][0] 'h' >>> x = [1,2,3,4,5] >>> x[0] = 10 >>> x [10, 2, 3, 4, 5] >>> #items in a list are lvalues >>> x [10, 2, 3, 4, 5] >>> x[1:4] [2, 3, 4] >>> #rosemary woods >>> x[1:4] = [] >>> x [10, 5] >>> x [10, 5] >>> x[1:1] [] >>> x[1:1] = [2,3,4] >>> x [10, 2, 3, 4, 5] >>> x[::2] [10, 3, 5] >>> x[1::2] [2, 4] >>> x [10, 2, 3, 4, 5] >>> 2 in x True >>> 9 in x False >>> "cat" in "caterwaul" True >>> x.find(2) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'find' >>> x.index(2) 1 >>> x.index(9) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: 9 is not in list >>> x [10, 2, 3, 4, 5] >>> str(x) '[10, 2, 3, 4, 5]' >>> list("trinitrotolulene") ['t', 'r', 'i', 'n', 'i', 't', 'r', 'o', 't', 'o', 'l', 'u', 'l', 'e', 'n', 'e'] >>> boom = list("trinitrotolulene") >>>