Hello! Numerical programming is becoming a key skill for modern engineers and you will need to use Python in some of your modules for labs and coursework. This is a quick introduction to numerical programming in Python using a set of interactive Jupyter notebooks.
- Python Basics
- Conditionals and Lists
- Numerical Python and Plotting
- Example: Potential flow plot
- Scientific Python library
You can use these notebooks in two ways:
- You can run the notebooks on google colab. This is extremely convenient, requiring nothing but a Google account! Just click the links above to get started.
- Alternatively, you can run the notebooks on your own machine. To do this, you need to download this github repository using the green
code
button above; for example as a zip file or using github desktop. If you haven't already, you should also install Anaconda. This will install Python and the Jupyter notebook environment, letting you run the notebooks locally.
I've also made a playlist on youtube going through the notebooks. You won't learn much from watching the videos alone! Make sure to complete the exercises by running the notebooks in one of the two ways described above.
The programming approach is highly preferred to using spreadsheets (like Excel
) which are extremely dangerous to use for important work. Well documented spreadsheet errors have led to catastrophes in business, economic policy and health care. This is because:
- Spreadsheets hide their methodology behind the data. This makes it difficult and error-prone to transfer methods to new data. In contrast, a program is the methodology, making testing and reproduction much easier.
- Spreadsheets are not extensible. Their limited numerical methods make them inappropriate for any advanced engineering analysis.
Python has a few important advantages as a numerical programming language:
- Python is in high demand. This means learning Python is a good way to improve your job prospects; particularly for engineering positions related to data-science and machine learning.
- Python has the largest community of users and developers. The figure above indicates that Python is around five times larger than any other programming language used for numerical work. This means Python is being continuously developed and tested, and it is very easy to get help.
- It is open-source and free to use. This helps the community grow and also ensures future employers can use your skills - no need to pay for a Matlab license.
- Python is easy to learn and the lessons are generally transferable to other languages. A basis in Python will help make other growing numerical languages like Julia and R more approachable.
This introduction is meant to get you familiar with numerical Python as quickly as possible. It assumes very little knowledge of programming, but accelerates quickly up to fairly advanced examples. If you are a complete beginner or if you prefer a slower pace then you might try these additional resources: