Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. >>> # Python shell session (edited) for Lecture 2 >>> # We went over numbers of different bases >>> # decimal is base 10; binary is base 2; octal is base 8 >>> # characters are stored as "ascii codes"; see Appendix C of the text >>> # operator precedence: >>> # **; then * / // %; then + - >>> # ()'s override precedence >>> 4 + 5 ** 3 129 >>> (4 + 5) ** 3 729 >>> 4 + 5 * 3 19 >>> (4 + 5) * 3 27 >>> #integer division throws out the decimal part >>> 5//2 2 >>> #modulus returns the remainder after integer division >>> 5 % 2 1 >>> # use the "help" function! >>> help(abs) Help on built-in function abs in module builtins: abs(...) abs(number) -> number Return the absolute value of the argument. >>> # All objects have types >>> 7 7 >>> type(7) >>> type(34.64) >>> type(8e-2) >>> type('hello world') >>> # you can convert from one type to another >>> int(7.999) 7 >>> float(4) 4.0 >>> str(123) '123' >>> int("12") 12 >>> int("hello") # this doesn't make sense so get an error Traceback (most recent call last): File "", line 1, in int("hello") # this doesn't make sense so get an error ValueError: invalid literal for int() with base 10: 'hello' >>> # i = j and j = i mean different things in programming languages! >>> i = 4 >>> j = 3 >>> i = j >>> i 3 >>> j 3 >>> i = 4 >>> j = 3 >>> j = i >>> i 4 >>> j 4 >>>