Hands-On Python Deep Learning for the Web
上QQ阅读APP看书,第一时间看更新

Jupyter Notebooks

A Jupyter Notebook by default is identified by the .ipynb extension. Upon clicking on the name of once such notebook in the file manager provided by Jupyter, you'll be presented with a screen resembling the following:

The topmost section, where you can see a menu bar, a toolbar, and the title of the notebook, is called the header. On the right side of the header you can see the environment in which the notebook is executing, and when any task is running, the white circle beside the environment language's name turns gray.

Below the header is the body of the notebook, which is composed of cells stacked vertically. Each cell in the body of the notebook is either a block of code, a markdown cell, or a raw cell. A code cell can have an output cell attached below it, which the user cannot edit manually. This holds the output produced by the code cell associated with it.

In a Jupyter Notebook, the keyboard behaves differently for different modes of a cell For this reason, these notebooks are called modal. There are two modes in which a notebook cell can operate: the command mode and the editx mode.

While a cell is in command mode, it has a gray border. In this mode, the cell contents cannot be changed. The keys of the keyboard in this mode are mapped to several shortcuts that can be used to modify the cell or the notebook as a whole.

While in command mode, if you press the Enter key on the keyboard, the cell mode changes to the edit mode. While in this mode, the contents of the cell can be changed and the basic keyboard shortcuts that are available in the usual textboxes in the browser can be invoked.

To exit the edit mode, the user can use the Esc key. To run the particular cell, the user has to input Shift + Return, which will do one of the following in each case:

  • For a markdown cell, the rendered markdown shall be displayed.
  • For a raw cell, the raw text as entered shall be visible.
  • For a code cell, the code will be executed and if it produces some output, an output cell attached to the code cell will be created and the output will get displayed there. If the code in the cell asks for an input, an input field will appear and the cell's code execution stalls until the input is provided.

Jupyter also allows the manipulation of text files and Python script files using its in-built text editor. It is also possible to invoke the system terminal from within the Jupyter environment.