How do I use Python?

There are basically two different ways to use the Python interpreter. First, you can work in an interactive Python session. This is possible because Python programs do not necessarily need to be compiled before they can be executed. A particularly nice way to do so, is to use a Jupyter notebook. Follow the link for install instructions and more information. In an interactive Jupyter session you can run fragments of code in separate code cells, having a pleasing interface in your webbrowser. Additionally, it is possible to add text, mathematic formulas and other material in cells directly next to your code. This is exactly what we require you to submit for example when you hand in your exercises: your answers in text form next to code you have written. And even when you are not reporting your code, the notebook is a convenient way to try things out and develope your code in small pieces. All code examples included in the tutorial on this site were prepared using Jupyter notebooks. A let’s say uncluttered interactive way to work with python, is to use a python shell in a terminal (see section Terminals), like ipython or a minimalistic built-in python session.

Todo

  • Link sources

  • Link section on terminals

  • Working with editors (command line/IDE)

The second fundamentally different way to execute Python code, is to write it to a text file (with the .py extension) and call the Python interpreter on it. If you write code that should be used more frequently or in another context, this is the way to go. The interpreter reads through file and executes line by line till the end. When it comes to editing text files that contain code