Introduction to Python + Jupyter

This notebook explains some fundamentals of the Python programming language and of Jupyter notebooks. It is intended for audiences without programming backgrounds that still would like to work with the AFwizard library. It is by no means a good introduction into programming with Python or Jupyter itself, as it only explains those parts necessary to work with AFwizard.

Python - an interpreted language

Python is an interpreted language: A program - the Python interpreter takes a piece of source code and executes (or interprets) it line by line. This is different from compiled languages, where the source code is translated into an executable program before running. In a normal setting, one would often invoke the Python interpreter manually with a .py file to interpret that Python file’s content.

What is a Jupyter notebook?

Jupyter Notebooks are a way of organizing Python code such that it can be easily combined with documentation, visualization and user interface controls. Jupyter notebooks are stored as .ipynb files and they are displayed in a web browser using an interactive frontend such as JupyterLab. You are currently looking at a Jupyter Notebook.

How to use a Jupyter notebook?

Jupyter notebooks are organized as cells. So far, all cells contained documentation (in the Markdown format) that was automatically rendered in the web frontend. The following cell, however is our first code cell:

[1]:
print("Hello World")
Hello World

In order to execute the Python code in the cell, we click the cell (so that it becomes the currently active cell) and press Shift+Enter. Try it with above cell! When doing so, Jupyter will send the code in the cell to the Python interpreter, which will execute it and send any results back to Jupyter which may then display that information to us in the web interface. We can repeat this process with other code cells. Note that we do not necessarily have to execute code cells in a Jupyter notebook top to bottom - although it makes sense most of the time.

Importing Python libraries

Most of the time, developers do not write Python code from scratch, but build on existing Python libraries. Libraries are Python code that is bundled for reuse in other projects. Libraries are either released as part of the Python standard library or provided by third parties e.g. through the Python Package Index PyPI. If installed, a library is imported into a Python project using the import statement. We will typically import the adaptivefiltering library at the beginning of our notebooks:

[2]:
import afwizard

Having done so allows us to access any functions or classes that library provides, like e.g. print the version of the adaptivefiltering library that we are using:

[3]:
afwizard.print_version()
1.0.0

Python variables, functions and classes

TODO: Continue

Troubleshooting

The above should give you enough knowledge to continue by looking at the other notebooks to learn about AFwizard’s capabilities. If you experience problems, here is a few things that might be helpful: