(base) MAC:Thu Feb 04:10:24:students> 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. >>> (base) MAC:Thu Feb 04:10:25:students> !p 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. >>> 5 + 6 11 >>> type(5) >>> 5*6 30 >>> 5**6 15625 >>> 5/6 0.8333333333333334 >>> type(5/6) >>> 5//6 0 >>> 5-6 -1 >>> # infix binary operators >>> #how many cubic feet are in a cubic mile? >>> 5280**3 147197952000 >>> 365%7 1 >>> 366%7 2 >>> 368%7 4 >>> 7*52 364 >>> 5-6 -1 >>> 5^7 2 >>> 2**1000 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376 >>> ## IEEE754 standard >>> ## this is a 64-bit floating point number >>> 2**64 18446744073709551616 >>> 2/3 0.6666666666666666 >>> .1 + .1 + .1 0.30000000000000004 >>> 1/4 0.25 >>> .1 + .1 +.1 == .3 False >>> 2.5 + 3.5 6.0 >>> 2.5 - 3.5 -1.0 >>> 2.5 * 3.5 8.75 >>> 2.5 / 3.5 0.7142857142857143 >>> 4**(.5) 2.0 >>> 4**(1/3) 1.5874010519681994 >>> 5 % 2.5 0.0 >>> 5.3 % 2.5 0.2999999999999998 >>> 7 + 6.5 File "", line 1 7 + 6.5 ^ IndentationError: unexpected indent >>> 7 + 6.5 13.5 >>> float(5) 5.0 >>> int(4.5) 4 >>> # cast is a temporary request to regard a datum as being of another type. >>> int(-4.5) -4 >>> ##truncates toward zero >>> z = complex(3,4) >>> z (3+4j) >>> z*z (-7+24j) >>> #order of ops is no surprise among arithmetic operators >>> 4 + 7*3 25 >>> 3*4/2*8 48.0 >>> # * and / have equal precedence and associate from left to right. >>> >>> 3-4+5-10 -6 >>> #associate from left to right. >>> 2**4**2 65536 >>> ## ** associates from right to left >>> >>> abs(-5) 5 >>> abs(-6.5) 6.5 >>> #Python has built-in functions that to lots of useful stuff. >>> ##Relational operators >>> 4 > 5 File "", line 1 4 > 5 ^ IndentationError: unexpected indent >>> 4 > 5 False >>> 5*6 < 2*4 False >>> ##relational have lower precedence than any arithmetic operator. >>> -5 -5 >>> -complex(3,4) (-3-4j) >>> -5.6 -5.6 >>> 5*6 >= 2*4 True >>> 5*6 <= 2*4 False >>> 5*6 == 30 True >>> # == is isequalto >>> .3 == .1 + .1 + .1 False >>> # do not compare floats for equality. >>> 5 != 6 True >>> type(False) >>> print("Hello") Hello >>> quit() (base) MAC:Thu Feb 04:11:05:students> pwd /Users/morrison/20202021/S2/4240/students (base) MAC:Thu Feb 04:11:06:students> cd ../ch2/ (base) MAC:Thu Feb 04:11:08:ch2> ls hello.py (base) MAC:Thu Feb 04:11:08:ch2> python hello.py (base) MAC:Thu Feb 04:11:09:ch2> python hello.py Hello, World! (base) MAC:Thu Feb 04:11:09:ch2> python hello.py Hello, World! 15 (base) MAC:Thu Feb 04:11:10:ch2> python hello.py Hello, World! 15 15 cows False 15 ** cows ** False No new line. please! a b c d e (base) MAC:Thu Feb 04:11:21:ch2> python format.py File "format.py", line 8 of this game"""") ^ SyntaxError: EOL while scanning string literal (base) MAC:Thu Feb 04:11:36:ch2> python format.py cat is chasing a dog 5 3 4 3 5*3 = 15 5*3 = 15 C:\Windoze\sux\bill\gates Here are the rules of this game (base) MAC:Thu Feb 04:11:37:ch2> 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. >>> #string: a glob of text >>> type("hello") >>> "some" + "thing" 'something' >>> "*"*50 '**************************************************' >>> print("5*3 = " + "15") 5*3 = 15 >>> "*"*(-4) '' >>> ##string literals can be bouned by single or double quotes >>> >>> 'sone' + 'thing' 'sonething' >>> 'some' + "thing" 'something' >>> 'double quotes like these " are not special when single quotes are used' 'double quotes like these " are not special when single quotes are used' >>> x = "abcdefghijklmnopqrstuvwxyz" >>> s Traceback (most recent call last): File "", line 1, in NameError: name 's' is not defined >>> x 'abcdefghijklmnopqrstuvwxyz' >>> len(x) 26 >>> x[1] 'b' >>> x[0] 'a' >>> x[2] 'c' >>> x[:2] 'ab' >>> x[2:] 'cdefghijklmnopqrstuvwxyz' >>> x[:2] + x[2:] 'abcdefghijklmnopqrstuvwxyz' >>> x[3:6] 'def' >>> x[50] Traceback (most recent call last): File "", line 1, in IndexError: string index out of range >>> x[::2] 'acegikmoqsuwy' >>> x[1::2] 'bdfhjlnprtvxz' >>> x[1:7:2] 'bdf' >>> #start, stop, skip >>>