/ITPP

Introduction to Python Programming

Primary LanguageJupyter NotebookOtherNOASSERTION

Introduction to Python Programming

A programming course suitable for beginners

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: 17-Jan-2018)

Binder

Welcome to Introduction to Python Programming. The course materials are divided into sections. You can use the links below to view each section in your browser.

  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. Nested Data Structures - an introduction to creating and working with more complex data structures
  4. Plotting Data - creating interactive plots with the matplotlib & bokeh libraries
The Language

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.

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.

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.

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

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 plotting exercises in Section4, for your reference.
Exercise 4.6
Exercise 4.7
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.

All materials written by:

  • Peter D Ashton (Department of Biology, University of York, UK)
  • Holger Dinkel (formerly of Gibson Team, European Molecular Biology Laboratory)
  • Toby Hodges (Zeller Team, European Molecular Biology Laboratory)
  • Karin Sasaki (EICAT, European Molecular Biology Laboratory)