6.18 KB
Newer Older
## Introduction to Python Programming
###### Materials for a course providing an introduction to programming in Python.

4 5
__Click the button below to launch the course materials in an interactive environment, thanks to the [Binder]( service from [The Freeman Lab]( (Current build of Binder materials: 22-Mar-2016)  

Toby Hodges's avatar
Toby Hodges committed
6 7

8 9
The course materials are divided into sections. You can use the links below to view each section in your browser. There is an overlap between the material in section 3 and in sections 4 & 5, which we recommend that you choose between. 

10 11 12 13 14
1. [Getting Started]( - an introduction to the basics of the language
2. [Beginning Programming]( - exploring some of the central concepts and operations of programming
3. [Input and Output]( - reading in, handling, and plotting data with the `matplotlib` library
4. [Nested Data Structures]( - an introduction to creating and working with more complex data structures
5. [Plotting Data With Bokeh]( - creating interactive plots with the `bokeh` library

##### The Language
Toby Hodges's avatar
Toby Hodges committed
17 18 19
Python is a high-level programming language, which is highly versatile, relatively accessible, and extremely well-supported. If you've never programmed before, Python is a great language to start with. A couple of the big reasons for this are: by the standards of programming languages, it is easy for humans to read; and, instead of spending a lot of time worrying about defining rigid types and arranging things in multiple files, it is quick to get started with actually _doing things_ with Python. 

This course focuses on handling tabular data and creating plots, but, after learning some of the language, you could use Python for a huge range of other tasks, such as: automating repetitive tasks; generating web content; processing images; creating cross-platform GUI applications; or writing programs to quickly perform complex analyses. These are just a few examples of the possibilities. 

##### The Course
This course provides an introduction to programming with the Python language. The course material is suitable for complete beginners, with no previous programming experience or knowledge required or assumed.  

24 25
The course was first written for a target audience of life scientists, and this is reflected in the simplistic example dataset used for the plotting exercises, but the material itself is designed to be accessible also for people with no scientific background, and the skills taught can be applied to a _much_ wider range of disciplines. Some knowledge of foundational mathematics is assumed.

26 27 28 29 30 31
The materials are split into broad sections, which we call worksheets, containing exercises for you to try and most of the information that you will need to complete them. The material covered is far from exhaustive. Instead, we try to provide enough information and tasks to get you started and we hope to get you quite quickly to a level where you are then capable to continuing to use Python for your own projects.

These materials are free to use. If you would prefer to attend a course in person, these are run in the Department of Biology at the [University of York](, UK. For a similar introduction to programming (as well as other essential computing skills), check out [Software Carpentry](

You can always get more information on any topic/object type/function etc. by looking at the Python help pages - type `help(object)` in the Python shell to get help on _object_ - or the 'cheat sheet', or by searching online. The online Python documentation (for [version 2.7]( or [version 3](, people's previous questions on [StackOverflow](, and a lot of the module homepages are very good places to start.  

32 33 34 35 36 37 38
If you work through the materials, you will learn:
* the basic concepts and building blocks of programming in Python
* how to quickly automate repetitive tasks and calculations
* the best ways of handling different types of data
* about working with the extensive catalogue of subject-specific modules available for Python
* how to read data from a file, process, and summarise it
* how to visualise data using Python’s powerful plotting libraries

40 41
We recommend using the [Anaconda distribution]( of Python. It's free and comes with a large number of additional modules included ready for importing into your scripts, IPython shell and notebook interfaces, a powerful Python text editor (Spyder), and a good package manager, _conda_, for updating and installing packages.   

As well as the main notebooks, we provide walkthroughs of the equivalent plotting exercises in Sections 3 and 5, for your reference.  
43 44
[Exercise 3.6](  
[Exercise 5.6](  
If you are taking the course, or working through the materials on your own, try to find your own solution to these exercises, and then use this ipynb if you get stuck, or want to compare your results to ours.

47 48 49 50 51
All materials written by:
* [Peter D Ashton]( (Department of Biology, University of York, UK)
* [Holger Dinkel]( (Gibson Team, European Molecular Biology Laboratory)
* [Toby Hodges]( (Zeller Team, European Molecular Biology Laboratory)
* [Karin Sasaki]( (Centre for Biological Modelling, European Molecular Biology Laboratory)