Introduction to 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 just to teach Python, but to teach you the basic concepts that all programming depends on. We use Python in our lessons because:

  • we have to use something for examples
  • it’s free, well-documented, and runs almost everywhere
  • it has a large (and growing) user base among scientists
  • 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 your work with them easily, and to use that language well.

Prerequisites:

In order to complete the tutorial you should be familiar with:

  • The linux command line

Schedule:

Approximate timings for the lesson:

Time Episode Description
0:00 Setup Get set(up)
0:10 Getting Started with Python Some first programs
0:30 Variables and Assignment How do we store and access data?
0:50 Jupyter Notebooks What's in a Jupyter notebook?
1:05 Datatypes and Conversion How does python store data?
1:35 Lists How can we store lists of data?
1:55 Looping How do we efficiently access data stored in lists?
2:25 Making Choices If then what or else
3:00 Creating Functions Functions contain modular blocks of code for reuse
4:00 Libraries Avoid reinventing the wheel
4:20 Reading Data How do we read data into python?
5:00 Command-Line Programs Combine all we've learnt to write useful programs