Skip to main content Skip to navigation

Short Course on Python with Applications

Introduction

This Python course has been taught to first-year Warwick undergraduate mathematics students. It is suitable for those new to programming as well as those with experience with other languages but interested in learning Python basics. The goal is to rapidly introduce you to some of the most important aspects of Python for mathematical and scientific work. You will learn to use powerful libraries that carry out complex tasks and allow you to concentrate on the "big picture". Examples are chosen to introduce modern applications, including ODEsLink opens in a new window, Monte Carlo integrationLink opens in a new window, stochastic differential equationsLink opens in a new window, Data ScienceLink opens in a new window, Machine LearningLink opens in a new window, and numerical linear algebraLink opens in a new window.

Course structure

This course is delivered as Guided Independent Study. You will work through a series of notebooks (Jupyter notebooks) that will teach you Python and allow you to practice what you have learnt. The notebooks and topics are organized by week, but you can work through more rapidly or more slowly.

Steps to completing this course:

  1. Install Anaconda
  2. Familiarize yourself with the JupyterLab interface
  3. Work through the weekly notebooks
  4. Complete the optional 5 assignments

Anaconda

Anaconda Individual EditionLink opens in a new window provides a (relatively) simple way to install all the software you will need. Anaconda provides both Python and JupyterLab which you will use extensively. It also provide many other packages that you may explore in the future. For example, we will demonstrate a few of the Data Science and Machine Learning libraries contained in Anaconda. You may be interested in exploring the Anaconda web pagesLink opens in a new window or the Anaconda wikipedia pageLink opens in a new window.

Follow the link above and install Anaconda now.

Running JupyterLab for the first time

Here we take you through running JupyterLab for the first time. We demonstrate the main features of the JupyterLab interface. Watch the first three videos. Play around with the JupyterLab interface, either after watching the videos or following along in real time as you watch.

JupyterLab Part 1Link opens in a new window - Infrastructure, navigation and first steps
JupyterLab Part 2Link opens in a new window - Notebooks, shortcuts and editing tips
JupyterLab Part 3Link opens in a new window - Kernels, order of operations and cell types

Note that JupyterLab is continually updated and hence the version you install may appear slightly different from the version in the videos. Further note that the third video end abruptly, but no content is missing.

Here is a checklist with the key interface functionality that you should be familiar with before you continue.

Weekly Notebooks

You probably want to keep each week's notebook in a separate folder. Each week the notebooks are numbered. Please work though notebooks in that order.

Week 1: Basic Python. week1.zip

Week 2: Functions and Libraries: NumPy for arrays and Matplotlib for graphics. week2.zip

Week 3: Ordinary Differential Equations and their Applications. week3.zip

Week 4: Monte Carlo Methods and their Applications. week4.zip

Week 5: Random Walks and Stochastic Differential Equations. week5.zip

Week 6: Visualising Functions and Data - Pandas and Seaborn. week6.zip

Week 7: Introduction to Machine Learning. week7.zip

Week 8: Introduction to Numerical Linear Algebra. (This week's notebooks are limited. I hope to expand on them at some point.) week8.zip

Assignments

You probably want to keep each assignment in a separate folder.

Assignment 1 (after completing week 1 and week 2 notebooks): Assignment1.zip

Assignment 2 (after completing week 3 notebooks): Assignment2.zip

Assignment 3 (after completing week 4 and week 5 notebooks): Assignment3.zip

Assignment 4 (after completing week 6 and week 7 notebooks): Assignment4.zip

Assignment 5 (after completing week 8 notebooks): Assignment5.zip

Solutions

Solution1.zip

Solution2.zip

Solution3.zip

Solution4.zip

Solution5.zip

Useful Websites

There are thousands on websites devoted to teaching Python. We have found the websites below particularly helpful and aligned with the goals of this course. The first will be especially helpful to students new to programming.

  • w3schoolsLink opens in a new window

    We highly recommend this site for clear elementary explanations and further practice. You can easily navigate to topics using the list on the left. We suggest bookmarking and consulting this site regularly.

  • The scipy lecturesLink opens in a new window

    These are more advanced than the w3schools tutorial, so they are a good place to turn as you become more advanced. We recommend this website because the focus is aligned with what we are teaching: "Most scientists are not payed as programmers, neither have they been trained so. They need to be able to draw a curve, smooth a signal, do a Fourier transform in a few minutes."

  • python-course.euLink opens in a new window

    This is also a good place to turn as you become more advanced and want a deeper understanding, perhaps as you get towards the end.

You will certainly be consulting the following web pages associated with the three main libraries used in this course.

and finally,

We pretty much have to list this one. It is worth checking out, but we do not recommend it as a resource for beginning Python. Throughout the module we will provide deep links to specific reference sections of the documentation.

Contact

If you find typos or errors in any of the notebooks, or have constructive criticism, please email .

It is not possible to provide individual help with Python or feedback on the assignments. Solutions to exercises in the weekly notebooks are found at the end of each notebook and model solutions to the assignments are provided. There are, or course, multiple ways questions can be answered, but the model solutions should be a useful guide.