Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Python and notebooks

Python

Python code is typically written in the form of functions that are stored in libraries (or modules) and made available with the import statement.

Python naturally invites to good software engineering practices in terms of object-oriented programming. Almost everything in Python is an object, with its properties and methods and a class is like an object constructor, or a “blueprint” for creating objects known as instances of the class.

It cannot be overemphasized that the use of object-oriented programming is highly enabling for code sharing and team development, and it is strongly recommended to adopt these practices.

Jupyter notebooks

A Jupyter notebook is an application to edit and run notebook documents via a web browser. A notebook document, in turn, is a human readable file in JSON format that contains both program code (written in e.g. Python) and text elements (paragraphs, figures, links, etc. using markdown) organized into cells. Notebook documents containing Python code have the file extension .ipynb.

You start a Jupyter notebook on the command line as follows

$ jupyter lab

Auto-completion

Press tab to auto-complete commands. If there is no unique completion available, a list of suggestions is provided.

E.g. if you enter plt. and press tab, you will get a list of the methods that pyplot implements.

Keyboard shortcuts

ShortcutResult
EnterEnter edit mode of cell
Shift-EnterLeave edit mode of cell
CCopy cell
VPaste cell
Shift MMerge cell with that below
Ctrl-Shift -Split markdown cell at cursor position
MChange cell to markdown type
YChange cell to code type
Ctrl-SSave checkpoint of notebook