Programming in Python

This lesson is an introduction to programming Python for people with little or no previous programming experience using analysis of tabular data as a motivating example. It is designed to be used in both Data Carpentry and Software Carpentry workshops. This lesson references the Jupyter Notebook, but can be taught using a regular Python interpreter as well. Please note that this lesson uses Python 3 rather than Python 2.

Prerequisites

Learners need to understand the concepts of files and directories (including the working directory) and how to start a Python interpreter before starting this lesson.

Learners must install Python and download the gapminder data before class starts: please see the setup instructions) for details.

Schedule

00:00 Running and Quitting How can I run Python programs?
00:15 Variables and Assignment How can I store data in programs?
00:25 Data Types and Type Conversion What kinds of data do programs store?
How can I convert one type to another?
00:35 Built-in Functions and Help How can I use built-in functions?
How can I find out what they do?
00:55 Error Messages What kind of errors can occur in programs?
How can I identify errors when they occur?
01:10 Libraries How can I use software that other people have written?
How can I find out what that software does?
01:20 Morning Coffee Break
01:35 Lists and Indexing How can I store multiple values?
01:55 For Loops How can I make a program do many things?
02:15 Reading Tabular Data into Data Frames How can I read tabular data?
02:30 Pandas Data Frames How can do statistical analysis of tabular data?
02:50 Plotting How can I plot my data?
03:10 Looping Over Data Sets How can I process many data sets with a single command?
03:25 Lunch Break
04:25 Conditionals How can programs do different things for different data?
04:40 Writing Functions How can I create my own functions?
05:05 Variable Scope How do function calls actually work?
05:30 Afternoon Coffee Break
05:45 Defensive Programming What sorts of things frequently go wrong in programs?
How can I make my programs more robust?
06:10 Programming Style How can I make my programs more readable?
How do most programmers format their code?
06:35 Next Steps What else is out there and where do I find it?
06:50 Wrap-Up What have we learned?
07:05 Finish