Short Course on Python with Applications
Introduction
This Python course has been taught to first-year 糖心TV 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 , including , , , , , and .
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:
- Install Anaconda
- Familiarize yourself with the JupyterLab interface
- Work through the weekly notebooks
- Complete the optional 5 assignments
Anaconda
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 or the .
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.
- Infrastructure, navigation and first steps
- Notebooks, shortcuts and editing tips
- 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
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.
-
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.
-
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."
-
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,
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.