Python and Jupyter notebooks#

This is a rapid introduction to the basics of Python and the use of Jupyter notebooks.

Good online cheatsheets:

What you should know from Python and Jupyter notebooks: part 01:

  1. Know how to switch between Code and Markdown cells and how to run them (shift-Return or Run button)

  2. Basics of Python evaluation and printing

    • string concatenation

    • exponentiation with **

    • use of fstrings

  3. Importing numpy and basic functions (sqrt, exp, sin, \(\ldots\))

    • numpy arrays using arange(min, max, step)

  4. Getting help via Google (or alternative): StackOverflow and manuals

  5. Defining functions in Python

    • def my_function(x): \(\longleftarrow\) semicolon and then indented lines

    • position vs. keyword argument and defaults

    • shift + tab + tab to reveal definitions

  6. Plotting with Matplotlib

    • Standard sequence for plot: data \(\longrightarrow\) make figure \(\longrightarrow\) add subplots \(\longrightarrow\) make plot

    • dressing up and saving a plot

    • names for the figure and axis objects are our choice

  7. Numpy linear algebra

    • defining a matrix and finding its shape or particular elements

    • matrix (or vector) operations: multiplying them with @, transpose, trace, inverse, eigensolution