Python is a highly expressive, easy to learn and widely popular programming language. There are many built in libraries and even more made available by third parties.
However, this comes at a cost: Python is notoriously slow.
This is mainly owed to the fact that Python is dynamically typed, which means that variable types are determined and checked at runtime rather than during compilation.
In addition, Python has the infamous Global Interpreter Lock (GIL). The GIL acts like a lock that allows only one thread to hold the control over the Python interpreter. As a result only one thread can be executed at a time. This actually results in a performance boost for single threaded programs, but poses a crucial bottleneck in parallel code.
So why use Python?
The versatility and ease of use of the language still makes it a great starting point for almost any project that involves code. Properly utilized libraries and techniques speed up parallel Python considerably. Overall we could argue that what you loose in performance compared to languages like C or Fortran, is probably negligible to what you gain in time by using a simple to understand programming language.
All course materials can be accessed *after the course* on our [python4hpc gitlab repository](https://gitlab.tuwien.ac.at/vsc-public/training/python4hpc).
You can hit the plus symbol on the top left to get to the launcher page. From there you can start a Jupyter Notebook, a Python console or a standard terminal. If you want to open an existing notebook, double click on it in the Files tab of the JupyterLab window.
A Jupyter notebook consists of cells. The two main types of cells you will use are **code cells** and **markdown cells**.
A **code cell** contains actual code that you want to run. You can specify a cell as a code cell using the pulldown menu in the toolbar of your Jupyter notebook. Otherwise, you can can hit `Esc` and then `y` while a cell is selected to specify that it is a code cell. Note that you will have to hit `enter` after doing this to start editing it.
If you want to execute the code in a code cell, hit `Enter` while holding down the `Shift` key (denoted Shift + Enter). Note that code cells are executed in the order you shift-enter them. That is to say, the ordering of the cells for which you hit Shift + Enter is the order in which the code is executed. If you did not explicitly execute a cell early in the document, its results are not known to the Python interpreter.
**Markdown cells** contain text. The text is written in markdown, a lightweight markup language. You can read about its syntax here. Note that you can also insert HTML into markdown cells, and this will be rendered properly. As you are typing the contents of these cells, the results appear as text. Hitting `Shift + Enter` renders the text in the formatting you specify.
You can specify a cell as being a markdown cell in the Jupyter toolbar, or by hitting `Esc m` in the cell. Again, you have to hit enter after using the quick keys to bring the cell into edit mode.
In general, when you want to add a **new cell**, you can click the `+` icon on the notebook toolbar. The shortcut to insert a cell below is `Esc b` and to insert a cell above is `Esc a`. Alternatively, you can execute a cell and automatically add a new one below it by hitting `Alt Enter`.
Make sure you shut down the kernel in use after completing a Notebook. You do this by clicking on the `Stop` symbol on the left and then `x-ing` the notebook for which you want to shut down the kernel. This releases the memory you used when running the notebook.