Last login: Mon Feb 7 08:12:20 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. MAC:Mon Feb 07:09:36:~> python Python 3.10.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:19) [Clang 12.0.5 (clang-1205.0.22.11)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> int(4.5) 4 >>> int(-4.5) -4 >>> int(1.5e100) 14999999999999999267208920533534235242810259434158468763468571810551997532349366721768062376180973568 >>> int(1.5555555555e100) 15555555555000000634775410563936071849876978208250285056660387478653424091320529666325108209909497856 >>> bool(2.3) True >>> bool(0) False >>> int("cows") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: 'cows' >>> str(True) 'True' >>> str(23) '23' >>> str(1.5e6) '1500000.0' >>> x = 3.4 >>> int(x) 3 >>> x = """This ... goes on ... and on ... and on ... and on""" >>> print(x) This goes on and on and on and on >>> ##single quotes can be used for triple quoted string >>> x = "foo" >>> x.capitalize() 'Foo' >>> x 'foo' >>> x.center(40) ' foo ' >>> x.center(40, "*") '******************foo*******************' >>> x.center(40, "bar") Traceback (most recent call last): File "", line 1, in TypeError: The fill character must be exactly one character long >>> state = "mississippi" >>> state.count("m") 1 >>> state.count("s") 4 >>> state.count("i") 4 >>> state.count("is") 2 >>> state.count("is", 5) 0 >>> state.count("is", 1, 5) 1 >>> state.endswith("i") True >>> state.endswith("pi") True >>> state.endswith("ippi") True >>> state.find("p") 8 >>> state 'mississippi' >>> state.rfind("p") 9 >>> state.rfind("quack") -1 >>> state.isalnum() True >>> foo = "cats;dogs" >>> foo.isalnum() False >>> x = "2344" >>> x.isdigit() True >>> x = "23 44" >>> >>> x.isdigit() False >>> "\t".isspace() True >>> print("quack\tmooo\tbaaaa") quack mooo baaaa >>> print("1\n2\n3\n") 1 2 3 >>> x = " space cadet " >>> x.strip() 'space cadet' >>> x = " space cadet \t\t\n " >>> x.strip() 'space cadet' >>> x = " space cadet \t\t\n " >>> x.strip() 'space cadet' >>> x.lstrip() 'space cadet \t\t\n ' >>> x.rstrip() ' space cadet' >>> x = "XXX is prohibited on the premises. You can't have XXX" >>> x "XXX is prohibited on the premises. You can't have XXX" >>> x.replace("XXX", "Likker") "Likker is prohibited on the premises. You can't have Likker" >>> x.replace("XXX", "Likker", 1) "Likker is prohibited on the premises. You can't have XXX" >>> ^D MAC:Mon Feb 07:10:02:~> !p python Python 3.10.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:19) [Clang 12.0.5 (clang-1205.0.22.11)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = 4 >>> y = 13 >>> print(f"{x}*{y} = {x*y}") 4*13 = 52 >>> x = r"C\Crap\BillGates\sux" >>> print(x) C\Crap\BillGates\sux >>> x = r"C\Crap\BillGates\sux\n\t" >>> print(x) C\Crap\BillGates\sux\n\t >>> x = r"C:\Crap\BillGates\sux\n\t" >>> x 'C:\\Crap\\BillGates\\sux\\n\\t' >>> f"""{x} is the root cause ... of Microsoft's crappiness""" "C:\\Crap\\BillGates\\sux\\n\\t is the root cause\nof Microsoft's crappiness" >>> y = f"""{x} is the root cause ... ... of Microsoft's crappiness""" >>> print(y) C:\Crap\BillGates\sux\n\t is the root cause ... of Microsoft's crappiness >>> print("\u3b1") File "", line 1 print("\u3b1") ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-4: truncated \uXXXX escape >>> print("\uo3b1") File "", line 1 print("\uo3b1") ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \uXXXX escape >>> print("\u03b1") α >>> print("\u03b2") β >>> print("\u03b3") γ >>> print("\u03b4") δ >>>