Notebook basics

Cell navigation: Command and Edit mode

The notebook distinguishes to two different navigation modes:

  1. Command mode: cursor keys can be used to move the highlighted cell. Press enter to move from Command mode to Edit mode.

  2. In edit mode, the content of a cell can be changed. To complete editing the cell, press SHIFT+RETURN to execute the cell or ESCAPE to go back to Command mode.

We recommend taking a tour of the notebook at some point (Help -> User Interface tour), and to explore the available short cuts (Help -> Keyboard Shortcuts).

Displaying objects


In [1]:
a = [10, 20, 30]   # create an example object
b = 42  # create another object

The standard method to display an object to standard output (that's normally the screen), is the print command:


In [2]:
print(a)


[10, 20, 30]

Within the notebook, the object or value of the last line is displayed:


In [3]:
a


Out[3]:
[10, 20, 30]

In [4]:
a
b


Out[4]:
42

To display multiple values within one cell, we need to use the print function:


In [5]:
print(a)
print(b)


[10, 20, 30]
42

If we want to supress output of the value/object of the last line, we can add ;:


In [6]:
a;

In [7]:
a


Out[7]:
[10, 20, 30]

Cell splitting, merging, moving

A number of useful commands are available under Edit, including merging, splitting and moving of cells within one notebook.

For many of those, there are shortcuts available. Use Help -> Keyboard Shortcuts to learn the short cut.

Inserting cells

We can insert cells via Insert -> Insert Cell Above or Insert -> Insert Cell Below. The short cuts in command mode are a (for above) and b (for below).

Execution of all cells

All cells in a notebook, or a subset (above or below the current cell) can be executed via the Cell menu.

Tidy up notebook at end of exploration

A useful command is Kernel -> Restart & Run all which

  • restarts the Python kernel
  • executes all cells in the notebook in order from the beginning.

This is useful to

  • ensure that all commands execute when the cells are called in linear order
  • obtain increasing numbering of input and output cells

Exporting notebooks

Notebooks can be exported to other file formats via the File -> Download as menu.