Last login: Mon Feb 7 13:33:38 on ttys005 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:14:01:~> 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("234") 234 >>> str(234) '234' >>> bool(3) True >>> bool(6) True >>> bool(0) False >>> bool(-6) True >>> bool(0.0) False >>> float(5) 5.0 >>> float(2**10000) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: int too large to convert to float >>> int(4.5) 4 >>> int(-4.5) -4 >>> int(1e100) 10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104 >>> int(1.2342332e100) 12342332000000000720094562463352703468167593571020121408730236554716854360539113449158086194481856512 >>> int("345", 7) 180 >>> int("346", 7) 181 >>> int("347", 7) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 7: '347' >>> int("350", 7) 182 >>> 0xabc 2748 >>> 0oabc File "<stdin>", line 1 0oabc ^ SyntaxError: invalid octal literal >>> 0o123 83 >>> hex(100) '0x64' >>> oct(100) '0o144' >>> bin(100) '0b1100100' >>> x = 3 >>> y = 7 >>> print(f"{x}*{y} = {x*y}") 3*7 = 21 >>> print(str(x) + "*" + str(y) + " = " _ str(x*y)) File "<stdin>", line 1 print(str(x) + "*" + str(y) + " = " _ str(x*y)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: invalid syntax. Perhaps you forgot a comma? >>> print(str(x) + "*" + str(y) + " = " + str(x*y)) 3*7 = 21 >>> print("1\n2\t3\n4\t5\t6") 1 2 3 4 5 6 >>> print(r"1\n2\t3\n4\t5\t6") 1\n2\t3\n4\t5\t6 >>> x = "C:\Bill Gates\sux\Microsoft\poop\nudnik" >>> print(x) C:\Bill Gates\sux\Microsoft\poop udnik >>> x = r"C:\Bill Gates\sux\Microsoft\poop\nudnik" >>> print(x) C:\Bill Gates\sux\Microsoft\poop\nudnik >>> quack = "I want File "<stdin>", line 1 quack = "I want ^ SyntaxError: unterminated string literal (detected at line 1) >>> duck for dinner" File "<stdin>", line 1 duck for dinner" ^^^ SyntaxError: invalid syntax >>> quack = """I want ... duck for dinner""" >>> print(quack) I want duck for dinner >>> print("""{x} sucks ... and I don't like it""") {x} sucks and I don't like it >>> print("""{x} sucks ... and I don't like it""") {x} sucks and I don't like it >>> print(f"""{x} sucks ... and I don't like it""") C:\Bill Gates\sux\Microsoft\poop\nudnik sucks and I don't like it >>> print(''' foo ... goo ... hoo ... boo ... boo''') foo goo hoo boo boo >>> x = """sfddfsfds ... ffewefw ... ffwe ... efwq ... f ... efw ... ewf ... fw ... ... f ... weffewew""" >>> print(x) sfddfsfds ffewefw ffwe efwq f efw ewf fw f weffewew >>> print("\u03b1") α >>> print("\u03b2") β >>> print("\u03b3") γ >>> print("\u03b4") δ >>> print("\u5525") 唥 >>> print(r"\u5525") \u5525 >>> x "cowabunga" File "<stdin>", line 1 x "cowabunga" ^^^^^^^^^^^ SyntaxError: invalid syntax >>> x = "cowabunga" >>> x.capitalize() 'Cowabunga' >>> x 'cowabunga' >>> y = x.capitalize() >>> y 'Cowabunga' >>> x.center(50) ' cowabunga ' >>> len(x.center(50)) 50 >>> len(x.center(5)) 9 >>> x.center(5) 'cowabunga' >>> x.center(5, "%") 'cowabunga' >>> x.center(50, "%") '%%%%%%%%%%%%%%%%%%%%cowabunga%%%%%%%%%%%%%%%%%%%%%' >>> x.center(50, "boo") Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: The fill character must be exactly one character long >>> x.center(50, "*") '********************cowabunga*********************' >>> x 'cowabunga' >>> x.count("a") 2 >>> x.count("q") 0 >>> x.count("a", 5) 1 >>> x.count("a", 5, 7) 0 >>> x[5:7] 'un' >>> x[:5] 'cowab' >>> x 'cowabunga' >>> x.endswith("ga") True >>> x.find("a") 3 >>> x.rfind("a") 8 >>> x.find("quack") -1 >>> "a" in "quack" True >>> "qu" in "quack" True >>> "quk" in "quack" False >>> "quack".isalphanum() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'isalphanum'. Did you mean: 'isalnum'? >>> "quack".isalnum() True >>> "qua4356ck".isalnum() True >>> "qua4;356ck".isalnum() False >>> " \t\t\n".isspace() True >>> x = "foo" >>> x.rjust(50) ' foo' >>> x.ljust(50) 'foo ' >>> x.ljust(50, '&') 'foo&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&' >>>