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:
Know how to switch between
Code
andMarkdown
cells and how to run them (shift-Return
orRun
button)Basics of Python evaluation and printing
string concatenation
exponentiation with
**
use of fstrings
Importing numpy and basic functions (sqrt, exp, sin, \(\ldots\))
numpy arrays using
arange(min, max, step)
Getting help via Google (or alternative): StackOverflow and manuals
Defining functions in Python
def my_function(x):
\(\longleftarrow\) semicolon and then indented linesposition vs. keyword argument and defaults
shift + tab + tab
to reveal definitions
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
Numpy linear algebra
defining a matrix and finding its shape or particular elements
matrix (or vector) operations: multiplying them with @, transpose, trace, inverse, eigensolution