## Week 11 agenda -- Python introduction

01 Nov 2011

### Programming introduction

We'll be writing our first traditional computer programs in class, but we'll make use of many concepts from earlier in the semester.

Some of those concepts include:

• giving names to data (variables)
• data types
• functions, including binary operations
• data organization
• data pipelines and processing input/output

We'll spend time going over how those concepts are used in our chosen programming language (Python).

### Python

Python is the programming language we'll use in class. Python programs are plain text files (like the HTML files we created, but with different syntax). The Python interpreter is used to run the programs. The full Python distribution includes the interpreter and many supporting libraries (called packages and modules in Python) that can be imported into your programs to help perform common tasks.

### Installing Python

On Windows, we'll use ActivePython, which is a package that includes the usual Python distribution and several useful utilities. Download the version 3 installer (3.2.2.3 is the version as of Nov 2), and run it, accepting all defaults. This will install Python and set it up so that you can run it from your command prompt.

After installing, use the pip command (which should have also been installed) to install another tool we'll use in class. In a command prompt, run:

pip install ipython


[update: this doesn't work on Windows yet; on Windows, one option is to just use the IDLE environment that comes with Python -- see this later post ] This will install a Python package that provides a nicer mode for interacting with the Python interpreter. To install the package, you might need to run the installation command from within an administrative command prompt. If so, you can open one by finding the command prompt entry in the start menu, right-clicking, and choosing "Run as administrator".

Once we start writing more complex programs, you might want to use pip to install other packages. You can browse and search the available packages at the Python Package Index (PyPI). Type pip help for more information on how pip works.

Once you've installed ipython, run the command ipython in the command prompt, and you'll have a nice prompt available to execute Python statements.

For other operating systems: Mac OS and most Linux distributions include Python by default. Let me know if you need help installing ipython.