Programming in Python, Spring 2020

Registration is closed, as the course has reached its full capacity.

Practical information

Your instructors are Peter Verhaar and Ben Companjen, digital scholarship librarians and software engineers at Leiden University Libraries' Centre for Digital Scholarship. If you have any questions or remarks, please feel free to reach out.


We request that you bring a laptop to the class with Python 3 installed. If possible, it saves time during the class if you already download the course materials before coming to class.

Install Python

We would like to ask you to bring your own laptop to the classes, and to make sure that you have installed a recent version of Python (Python 3.7 or higher) before coming to the first session. We strongly advise you to install the Anaconda distribution of Python 3. The installation files can be found at the following address:

On this page, you can find separate instructions for Windows, Mac and Linux. Next to Python itself, the Anaconda distribution also contains Jupyter Notebook, an environment that can be used to document and to execute Python code. We will use Jupyter Notebooks in this course.

See Anaconda's installation instructions for some important points to consider during installation. For example, the installation path must not contain spaces. If you want to use Anaconda Python from the command line, it helps to add Anaconda to your PATH during the installation, even though this is not recommended by the installer.

If you experience difficulties during the installation of this software, do not hesitate to contact the CDS via email. If necessary, you can make an appointment and ask us to help you install the software. On the 6th of March, the course instructors shall be present in the Heinsius room from 9:00h onwards, to address any technical issues, if needed.

Download the course materials

This is optional, though downloading the course materials beforehand should save some time in class. We may update the materials between classes; if we do we will say so at the start of the class.

The latest version of the course materials is available as a zip file at When you download and unzip this, make sure you put the directory (PythonCourse-master by default) in a location that you can access from the Jupyter Notebook environment – your home directory should be a good location.

Course setup

In the course Peter en Ben will explain and demonstrate Python programming through live coding and prepared pieces of source code. These pieces are available in the tutorials below. The HTML version can be viewed in the browser directly, the Notebook can be downloaded and opened in Jupyter Notebook.
If you downloaded the zip file, you don't need to download the individual notebooks.

There are exercises to allow you to apply the knowledge; their numbering follows the tutorials.
Solutions are also provided for the exercise questions.

If you like to challenge yourself, have a look at the coding challenges.

We have also created a page that lists a number of additional tutorials.

Coding challenges

The coding challenges test your understanding of the course materials. they bring together the various topics that are discussed in the tutorial.

Don't be afraid to look for documentation and help outside these course materials!

Good luck!

Video tutorials

We have also recorded video tutorials on some of the topics that are covered in this course:


In addition to following the biweekly classes, we would like you to do a number of tasks in preparation for these sessions.

The homework for the second sesssion on 20 March is as follows:

  • Read the Python tutorial, sections 1 up and until 6.
  • Do all the exercises in the sections 1 up and until 4. Some of these exercises have already been discussed during the class on March 6. Also note that the solutions are also provided on this website.
  • Attempt to write code for Coding challenges 1 and 2.

Update: The physical session on 20 March was cancelled due to the Covid-19 crisis, but the tasks mentioned above formed the homework for the online session which was organised as a replacement on 13 May.

The homework for the third session (which will also take place online via the Kaltura Live Room channel that can be accessed via ) consists of the following tasks:

  • Read the Python tutorial, sections 7, 8, 9 and 11.
  • Optionally, watch the video tutorials on regular expressions and pandas.
  • Do exercises 8.3, 9.1, 9.5, 11.1 and 11.2. While making these exercises, please make a list of aspects that you find unclear and that need to be discussed in more detail during the online session.

The homework for the fourth session on 27 May is as follows:

  • Read the Python tutorial, section 12.
  • Optionally, watch the video tutorial on data visualisation.
  • Do exercises 11.2, 11.3, 12.1, 12.2 and 12.3.
  • Collect ideas on you would like to continue the process of learning Python and on what Leiden University can do to support this process.