Last login: Tue Feb 9 08:39:04 on ttys007 pyth 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:Tue Feb 09:09:39:~> 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. >>> not P Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'P' is not defined >>> not True False >>> not False True >>> True or True True >>> True or False True >>> False or True True >>> False or False False >>> True and True True >>> True and False False >>> False and True False >>> False and False False >>> #lists >>> x = [] >>> x.append("cows") >>> x ['cows'] >>> x.append("sheep") >>> x ['cows', 'sheep'] >>> x.append(42) >>> x ['cows', 'sheep', 42] >>> #lists are heterogeneous >>> x.append([1,2,3,4]) >>> x ['cows', 'sheep', 42, [1, 2, 3, 4]] >>> x[0] 'cows' >>> x[3].append(["cats", "dawgs", "elliefants"]) >>> x ['cows', 'sheep', 42, [1, 2, 3, 4, ['cats', 'dawgs', 'elliefants']]] >>> x[0] 'cows' >>> x[0][0] 'c' >>> x[3] [1, 2, 3, 4, ['cats', 'dawgs', 'elliefants']] >>> x[3][4 ... ] ['cats', 'dawgs', 'elliefants'] >>> x[3][4][2] 'elliefants' >>> x[3][4][2][0] 'e' >>> list("trinitrotolulene") ['t', 'r', 'i', 'n', 'i', 't', 'r', 'o', 't', 'o', 'l', 'u', 'l', 'e', 'n', 'e'] >>> smithereens = list("trinitrotolulene") >>> "".join(smithereens) 'trinitrotolulene' >>> shopping = [] >>> shopping.append("steak") >>> shopping.append("broccoli") >>> shopping.append("chocolate milk") >>> shopping ['steak', 'broccoli', 'chocolate milk'] >>> len(shopping) 3 >>> "milk" in shopping False >>> shopping.add("milk") Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'add' >>> shopping.append("milk") >>> "cow" in "cowabunga" True >>> #string, numbers, booleans >>> #lists are mutable >>> #aliasing >>> x = [1,2,3] >>> y = x >>> y [1, 2, 3] >>> x [1, 2, 3] >>> y[0] = 5 >>> y [5, 2, 3] >>> x [5, 2, 3] >>> id(x) 140363846671296 >>> id(y) 140363846671296 >>> id(0) 4462098752 >>> id(1) 4462098784 >>> id(2) 4462098816 >>> id(3) 4462098848 >>> id(5) 4462098912 >>> id(100) - id(0) 3200 >>> id(200) - id(0) 6400 >>> id(300) - id(0) 140359387297968 >>>