Math Normal with normal order of operation 5//2 -- integer division yield 2 not 2.5 5**2 -- power yields 25 x++ -- There is no ++, but there is x+=1 Data Structures List Ordered, duplicates allowed http://euclid.nmu.edu/~rappleto/Classes/CS295.Python/list_quiz_answers.py Make a list l = [] l = [1,2,3] Lists in lists l = [1,2,[3,4,5]] print(l[2][1]) Length of a list len(l) Slices l[0:2] -- Items 0 and 1 but not 2 l[3:] -- Items from 3 to the end l[:3] -- Items 0,1,and 2 l[-4] -- Forth item FROM THE END l[-4:-2] -- Some items near the end Item existance if "fred" in words: Appending l.append("apple") l.append(["pear", "orange"]) -- adds ONE item to the list Removing from a list l.remove("pear") l.pop() -- remove the last item del l[2] Sorting a list l.sort() Reversing a list l.reverse() My favorite l.shuffle() Set (Only a little bit) No duplicates No order (so no sort, shuffle, etc) Making a set s = {"apple", "bananna"} s = set((1,2,3)) -- double parenthesis! s = {} -- makes a dictionary not a set!!! Adding an item s.add("pear") Check Membership if "pear" in s: Remove from a set s.remove("pear") Array Use a list Tuple (only a little bit) Like a read only list So no add, remove, shuffle, t = (1,2,3,4) Dictionary Like a list with strings as indexes Order is weird d = {"Randy":52, "Scott":41} For loops for key, value in d.items(): String s = "Dead Parrot" works almost like a list with for loops, slices, etc. Control Structures And is spelled either "and" or "&&" Or is spelled either "or" or "||" For loop for num in range(4): -- does 0,1,2,3 for num in range(2,5): -- does 2,3,4 for num in range(2,22,3): -- does 2,5,8,11,14,17,21 for num in range(len(l)): -- sometimes what you want for item in l -- other times what you want for key, value in d.items(): -- iterate thru a dictionary While loop while x < 3: If statement if b > a: print("b is greater than a") elif a == b: print("a and b are equal") else: print("a is greater than b") PIP (Just that it exists) The Python installer program Uses a library of modules stored "in the cloud" pip3 install thing -- on the command line Python functions def fred(x): return x+4 y = fred(17) # with a default value def wilma(x = 3): return x + 4 z0 = wilma() z1 = wilma(2) File Stuff for name in os.listdir("/home/fred"): file = open("fred.txt", "r") glob Other file stuff Routes Can have method= for just post or just get Can have URL pattern matching @app.route('/hello/') def index(): return render_template(‘hello.html’,name = user) Templates Can pass in variables. Have their own if {% if marks>50 %}

Your result is pass!

{% else %}

Your result is fail

{% endif %} Have their own for loop {% for key, value in result.iteritems() %} {% endfor %}
{{ key }} {{ value }}
AJAX Know how to