Editing DS4UX (Spring 2016)/Day 2 lecture
From CommunityData
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
== | == Resources == | ||
* [[Python data types cheat sheet]] | |||
* [[Python loops cheat sheet]] | |||
* [http://mako.cc/teaching/2015/cdsw-spring/state_capitals.py state_capitals.py] -- the state capitals example. | |||
* [http://communitydata.cc/~mako/cdsw-au2015-lecture1-20151010.ogv cdsw-au2015-lecture1-20151010.ogv] -- Professor Mako Hill's lecture video, which covers most of the concepts from today's lecture. | |||
== Lecture outline == | |||
=== Review Day 1 material === | |||
* math: using python as a calculator | * math: using python as a calculator | ||
**addition, subtraction, multiplication, division | **addition, subtraction, multiplication, division | ||
Line 24: | Line 34: | ||
** type() shows that the output of True or False is <code>bool</code> | ** type() shows that the output of True or False is <code>bool</code> | ||
** e.g., <code>"i" in "team"</code> | ** e.g., <code>"i" in "team"</code> | ||
** e.g., | ** e.g., "i" not in "team"</code> | ||
* <tt>if</tt>/<tt>elif</tt>/<tt>else</tt> ('''move to external file''') | * <tt>if</tt>/<tt>elif</tt>/<tt>else</tt> ('''move to external file''') | ||
** if, something that evaluates to a boolean, and then colon | ** if, something that evaluates to a boolean, and then colon | ||
** e.g., <code>if "mako" in "makoshark"</code> | ** e.g., <code>if "mako" in "makoshark"</code> | ||
** e.g., adding else example: <code>if brother_age > sister_age</code> | ** e.g., adding else example: <code>if brother_age > sister_age</code> | ||
** e.g., | ** e.g., tempreature range | ||
** e.g., adding elif: fix the bug in the previous program if they were the same age | ** e.g., adding elif: fix the bug in the previous program if they were the same age | ||
** indent with spaces (we use 4 spaces!) | ** indent with spaces (we use 4 spaces!) | ||
Line 36: | Line 46: | ||
** we've already learnd examples of this: exit(), help(), type() | ** we've already learnd examples of this: exit(), help(), type() | ||
=== Lists === | === Lists === | ||
Line 73: | Line 82: | ||
=== loops and more flow control === | === loops and more flow control === | ||
* <tt>for</tt> loops | * <tt>for</tt> loops | ||
Line 95: | Line 103: | ||
* <tt>break</tt> | * <tt>break</tt> | ||
* <tt>input()</tt> | * <tt>input()</tt> | ||
=== dictionaries === | |||
* purpose | |||
* initialization | |||
* accessing elements | |||
* adding elements | |||
* changing elements | |||
* <tt>keys()</tt> and <tt>values()</tt> | |||
=== modules === | === modules === | ||
* purpose | * purpose | ||
* builtins | * builtins | ||
* imports | |||
* <tt>import random</tt> | * <tt>import random</tt> | ||
* <tt>random.randint</tt> | * <tt>random.randint</tt> | ||
* <tt>random.choice</tt> | * <tt>random.choice</tt> | ||
=== walk through | === 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. | |||
[[Category:DS4UX (Spring 2016)]] | [[Category:DS4UX (Spring 2016)]] |