DS4UX (Spring 2016)/Day 2 lecture

Resources

 * Python data types cheat sheet
 * Python loops cheat sheet
 * state_capitals.py -- the state capitals example.
 * cdsw-au2015-lecture1-20151010.ogv -- Professor Mako Hill's lecture video, which covers most of the concepts from today's lecture.

Lists

 * purpose
 * Stores things in order
 * initialization
 * making a list called my list:
 * comma separated elements. in python they can be a mix of any kind of types
 * len review
 * accessing elements
 * indexing like my_list[0]
 * indexing starts from the front and we start counting at 0 (now you understand all the zeros we've been using)
 * we go from the end with negative numbers
 * what happens if we try to move outside of the range? ('error!)
 * adding elements
 * using the the  function
 * the  function is a special kind of function that lists know about
 * changing elements
 * replacing elements like
 * finding elements in list
 * e.g.,
 * slicing lists
 * the colon inside the [] is the slicing syntax
 * e.g.,  is 0th up to, but not including, the 2nd
 * e.g.,
 * e.g.,
 * e.g.,
 * strings are like lists
 * we can slice lists
 * len
 * length of the empty string
 * many other interesting functions for lists
 * e.g.,  and
 * e.g., create a list of names and sort it
 * e.g., create a list of names and sort it

loops and more flow control

 * for loops
 * e.g.,
 * e.g.,
 * Super powerful because it can do something many many times. Data science is about doing tedious things very quickly. For is the workhorse that makes this possible.
 * Look and see name is after we're done looping.
 * Move to editor.
 * if statements inside for loops
 * e.g.,  then print "starts with a vowel"
 * show we can test things outside the loop to show how the comparisons are working
 * add an else statement to capture words that start with a consonant
 * append to a list within a for loop
 * create a counter within a for loop (keep track)
 * build up a sentence
 * nested for loops
 * range
 * while loops
 * infinite loops
 * if statements inside while</tt> loops
 * break</tt>
 * input</tt>

dictionaries

 * purpose
 * initialization
 * accessing elements
 * adding elements
 * changing elements
 * keys</tt> and values</tt>

modules

 * purpose
 * builtins
 * imports
 * import random</tt>
 * random.randint</tt>
 * random.choice</tt>

walk through state_capitals.py
Where state_capitals.py from http://mako.cc/teaching/2015/cdsw-spring/state_capitals.py is the grand finale and synthesis of lecture material.