This page was generated from `/home/lectures/exp3/source/notebooks/Intro/NotebookEditor.ipynb`_.
Notebook editor¶
A Jupyter Notebook provides an interface with essentially two modes
edit mode the mode where you edit a cell’s content.
command mode the mode where you execute the cells content.
In the more advanced version of JupyterLab, which we are using on myBinder, this will look like that
Edit mode¶
Edit mode is indicated by a blue cell border and a prompt showing in the editor area:
When a cell is in edit mode, you can type into the cell, like a normal text editor.
Command mode¶
Command mode is indicated by a grey cell border:
Running code¶
Code cells allow you to enter and run code. Run a code cell by pressing the ▶︎
button in the bottom-right panel, or Control
+Enter
on your hardware keyboard.
[1]:
v = 10
[5]:
print(v)
100
There are a couple of keyboard shortcuts for running code:
Control
+Enter
runs the current cell and enters command mode.Shift
+Enter
runs the current cell and moves selection to the one below.Option
+Enter
runs the current cell and inserts a new one below.
Managing the kernel¶
Code is run in a separate process called the kernel, which can be interrupted or restarted. You can see the kernel indicator in the top-right corner reporting the current kernel state: ⚪︎
means the kernel is ready to execute code, and ⚫︎
means the kernel is currently busy. Tapping kernel indicator will open the kernel menu, where you can reconnect, interrupt or restart the kernel.
Try running the following cell — kernel indicator will switch from ⚪︎
to ⚫︎
, i.e., reporting the kernel as “busy”. This means that you will not be able to run any new cells until the current execution finishes, or until the kernel is interrupted. You can then go to the kernel menu by tapping the kernel indicator and select “Interrupt”.