Columbus Python Workshop 1/Friday

Welcome to the Friday evening section of the Columbus Python Workshop!

When you get to Pillar, please start your laptop and get on the wireless network. Then work through the goals on this page in order; they should take between 2 and 3 hours. Lots of staff will be around to help troubleshoot and to answer questions -- don't hesitate to ask!

At the end, a staff member will go through a checklist with you to make sure you're all set for tomorrow. Please be sure to do this checkoff before you leave -- it'll make sure that you are in good shape for tomorrow.

Goal #1: set up Python
This section has instructions for installing Python and running Python from a command prompt.


 * Windows
 * OS X
 * Linux

Goal #2: prepare a text editor
In addition to being able to run Python, we are going to install a good text editor for writing and saving Python code during the workshop.

If you would like to use a different text editor from the recommendation for your operating system, please let a staff member know.


 * Windows
 * OS X
 * Linux

Goal #3: practice starting and exiting Python
We'll do a lot of learning and practicing at a Python prompt (this is "interactive" because you are typing the code and hitting enter to run it yourself, instead of running it from a file). So let's practice starting and exiting Python:


 * Windows
 * OS X
 * Linux

Goal #4: practice navigating the computer from a command prompt
We will be running files containing Python code (Python "scripts") from the command prompt. You'll need to be able to navigate to those scripts using the command prompt so you can run them. In this section, we'll practice using these navigation commands.


 * Windows
 * OS X
 * Linux

Goal #5: practice running Python code from a file
Interactive Python programming at a Python prompt is great for short pieces of code and for testing ideas. For longer code, it can be easier to save the code in a file, and execute the contents of that file (aka a Python script). In this section, we'll practice running Python scripts.


 * Windows
 * OS X
 * Linux

Goal #6: get dependencies installed for the Saturday projects

 * Windows
 * OS X
 * Linux

Goal #7: start learning Python!
It's time to start learning, reading, and writing some Python! Tonight, you'll work through a self-directed tutorial. Saturday morning, we'll have an interactive lecture to cover more Python basics.

&raquo;Click here to work through tonight's tutorial&laquo;

Goal #8: practice Python using IPython Notebook

 * In case of pyzmq errors:** Instead of the IPython notebook, you can work through the same exercises at an online site called CodingBat: https://openhatch.org/wiki/Boston_Python_Workshop_6/Friday/CodingBat_Using_Codingbat

Learning about functions opened up a whole new way for us to practice, using an IPython Notebook with programming problems. The big goal of this practice section is to get you thinking about how to solve problems in Python.

IPython Notebook is a special Python application that lets you run little Python sessions right within the browser. Here's how to get started with the IPython Notebook.

1. Copy the file exercises.ipynb from the CD, the instructor's USB drive, or from here. Save it to your desktop (or any other directory you know how to get to).

2. In a Terminal or Command Prompt window, use cd to move into the directory containing exercises.ipynb.

3. Type ipython notebook. In the browser window that appears, click on exercises.

4. At the very top of the notebook is a cell containing several lines of code:

from ipython_doctester import test import ipython_doctester ipython_doctester.workshop_name = None ipython_doctester.student_name = None ipython_doctester.verbose = True

Replace the workshop_name and student_name, like so. Please use cmh for the workshop name:

ipython_doctester.workshop_name = 'cmh' ipython_doctester.student_name = 'Catherine'

5. Hold down SHIFT and hit ENTER. You'll always use this key sequence to tell IPython Notebook to go ahead and execute the code in the cell you've been working in. Until you hit SHIFT+ENTER, IPython Notebook doesn't "see" the code you've been typing.

6. Now work your way down the notebook. Each code cell contains the beginning of a function, but no code... except for a documentation string. Within that documentation string is what looks like the transcript of a short Python session in which the function is used. Those are called doctests. Your goal is to try to write the actual code for the function so that it acts the way the doctests describe it as working. Hit SHIFT+ENTER to execute the code and run the tests. You can try as many times as you need to until all the tests pass!

7. Before you close the browser tab containing IPython Notebook, use the save button to save your work for later! (There's no autosave.)

Goal #9: Checkoff
Tell a staff member that you are ready to be checked off. Together you will go through the following check-off steps:

  Start a command prompt, and from that command prompt start Python. Then quit Python.   Create a new Python file (with a .py extension). In that file, type

print "Hello World"

and save the file. From a command prompt, navigate to and execute that Python script.   Open your text editor, and press "Tab". Use the left arrow key to show the instructor that you are using spaces to indent, not tabs.   To test the ColorWall installation: navigate to the ColorWall directory and run :

python run.py -a   To test the Wordplay installation: navigate to the Wordplay directory and run :

python words1.py  To test the Twitter installlation, navigate to the Twitter directory and run :

python twitter_api.py --search=python 

 Walk through the CodingBat problem that you had the most difficulty with. The Friday CodingBat questions are here.  

If you have any other questions about the tutorial, project setup, or CodingBat questions, now is a great time to ask!

Congratulations!
You are done with the Friday portion of this Workshop. We'll see you at 9:30am tomorrow back here at Pillar! Please bring the laptop you used tonight.

If you have any questions, comments, or feedback on tonight's material, don't hesitate to let a staff member know.

&laquo; Back to the Workshop home page