# log from lecture 1, 2/13/17, DS Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> # I'll use comments (lines starting with '#') to provide a few explanations # basic math >>> 2+3 5 >>> 1+1+1 3 >>> 1 + 1 + 1 3 >>> 2 + 3 * 4 14 >>> (2 + 3) * 4 20 >>> 3 * -4 -12 >>> 20 / 4 5.0 >>> 10 / 4 2.5 >>> 10 // 4 # integer division (a comment!) 2 >>> 97 // 10 9 >>> 97 % 10 # remainder 7 >>> 97 / 10 9.7 >>> -97 / 10 -9.7 >>> -97 // 10 -10 >>> 8 ** 2 64 >>> 81 ** 0.5 9.0 >>> float(2) 2.0 >>> int(2.9) 2 # assigning a value to a variable: >>> x = 2 >>> x 2 >>> 2 = x # this won't work -- the variable has to be on the left File "", line 1 SyntaxError: can't assign to literal >>> x = 5 # you can re-assign, which overwrites the old value >>> x 5 # bbq party # - you're having a party and you're trying to figure out how many hot dogs to buy. Here's what you know: # - tim isn't a big fan of hot dogs, so he'll only eat 1 # - amy generally eats 2 # - todd always eats twice as many as amy # - brenda eats one less than todd # - mark eats half as many as brenda, but likes to take an extra on his way home >>> tim = 1 >>> amy = 2 >>> todd = 2 * amy >>> brenda = todd - 1 >>> brenda 3 >>> mark = brenda / 2 # this is 1.5, but need whole hot dogs >>> mark = brenda // 2 # rounds down instead of up... >>> mark = (brenda + 1) // 2 # but this rounds up! >>> mark = (brenda + 1) // 2 + 1 # remember, one more for the way home >>> total_hotdogs = tim + amy + todd + brenda + mark >>> total_hotdogs 13 >>> runfile('C:/Users/schar/Desktop/cs150/bbq.py', wdir='C:/Users/schar/Desktop/cs150') >>> brenda 3 >>> brenda // 2 1 >>> brenda / 2 1.5 >>> (brenda + 1)// 2 2 >>> runfile('C:/Users/schar/Desktop/cs150/bbq.py', wdir='C:/Users/schar/Desktop/cs150') 13 >>>