Fork me on GitHub

Programming with Python

The best way to learn how to program is to do something useful, so this introduction to Python is built around a common scientific task: data analysis.

Our real goal isn't to teach you Python, but to teach you the basic concepts that all programming depends on. We use Python in our lessons because:

  1. we have to use something for examples;
  2. it's free, well-documented, and runs almost everywhere;
  3. it has a large (and growing) user base among scientists; and
  4. experience shows that it's easier for novices to pick up than most other languages.

But the two most important things are to use whatever language your colleagues are using, so that you can share you work with them easily, and to use that language well.

iPython Notebook

We will be using iPython notebook for these lessons.

To open iPython notebook, open a new terminal (gitbash for windows) invoke:


$ ipython notebook


  • This will open a new page/tab in your web browser
  • Leave your terminal window open while using iPython
To open first lesson in your browser, click the "click here" link in iPython Notebook

Navigate to the lesson:

~/2015-01-08-unl/unl_lessons/python/variables.ipynb)

Note: We assume you installed the course material in your home directory (~/ ), otherwise, navigate to the location of your 2015-01-08-unl folder.

Variables

Lesson:

~/2015-01-08-unl/unl_lessons/python/vars-types/variables.ipynb

Excercises:

~/2015-01-08-unl/unl_lessons/python/vars-types/excercises.ipynb

Data structures

Lesson:

~/2015-01-08-unl/unl_lessons/python/data-structures/data-structures.ipynb

Excercises:

~/2015-01-08-unl/unl_lessons/python/data-structures/excercises.ipynb

Flow control

~/2015-01-08-unl/unl_lessons/python/python-flowcontrol/python_flow_control.ipynb

Functons and modules

~/2015-01-08-unl/unl_lessons/python/python-functions/python_functions_and_modules.ipynb

Numerical Python (NumPy)

~/2015-01-08-unl/unl_lessons/python/numpy/numpy-short.ipynb

Python Data Analysis Library (PANDAS)

~/2015-01-08-unl/unl_lessons/python/pandas/an-introduction-to-pandas.ipynb

Defensive Programming

~/2015-01-08-unl/unl_lessons/python/defensive/05-defensive.ipynb

Errors

~/2015-01-08-unl/unl_lessons/python/errors/07-errors.ipynb