|
98 | 98 | "cell_type": "markdown", |
99 | 99 | "metadata": {}, |
100 | 100 | "source": [ |
101 | | - "Through IPython's kernel and messaging architecture, the Notebook allows code to be run in a range of different programming languages. For each notebook document that a user opens, the web application starts a kernel that runs the code for that notebook. Each kernel is capable of running code in a single programming language and there are kernels available in over [100 programming languages](https://github.com/jupyter/jupyter/wiki/Jupyter-kernels); some of the most popular are:\n", |
| 101 | + "Through IPython's kernel and messaging architecture, the Notebook allows code to be run in a range of different programming languages. For each notebook document that a user opens, the web application starts a kernel that runs the code for that notebook. Each kernel is capable of running code in a single programming language and there are kernels available in over [100 programming languages](https://github.com/jupyter/jupyter/wiki/Jupyter-kernels).\n", |
102 | 102 | "\n", |
103 | | - "* Python(https://github.com/ipython/ipython)\n", |
104 | | - "* Julia (https://github.com/JuliaLang/IJulia.jl)\n", |
105 | | - "* R (https://github.com/takluyver/IRkernel)\n", |
106 | | - "* Ruby (https://github.com/minrk/iruby)\n", |
107 | | - "* Haskell (https://github.com/gibiansky/IHaskell)\n", |
108 | | - "* Scala (https://github.com/Bridgewater/scala-notebook)\n", |
109 | | - "* node.js (https://gist.github.com/Carreau/4279371)\n", |
110 | | - "* Go (https://github.com/takluyver/igo)\n", |
111 | | - "\n", |
112 | | - "The default kernel runs Python code. \n", |
| 103 | + "[IPython](https://github.com/ipython/ipython) is the default kernel, it runs Python code.\n", |
113 | 104 | "\n", |
114 | 105 | "Each of these kernels communicate with the notebook web application and web browser using a JSON over ZeroMQ/WebSockets message protocol that is described [here](https://jupyter-client.readthedocs.io/en/latest/messaging.html#messaging). Most users don't need to know about these details, but it helps to understand that \"kernels run code.\"" |
115 | 106 | ] |
|
156 | 147 | "Furthermore, any notebook document available from a **public URL on or GitHub can be shared** via http://nbviewer.jupyter.org. This service loads the notebook document from the URL and renders it as a static web page. The resulting web page may thus be shared with others **without their needing to install Jupyter**." |
157 | 148 | ] |
158 | 149 | }, |
| 150 | + { |
| 151 | + "cell_type": "markdown", |
| 152 | + "metadata": {}, |
| 153 | + "source": [ |
| 154 | + "### Body\n", |
| 155 | + "\n", |
| 156 | + "The body of a notebook is composed of cells. Each cell contains either markdown, code input, code output, or raw text. Cells can be included in any order and edited at-will, allowing for a large ammount of flexibility for constructing a narrative.\n", |
| 157 | + "\n", |
| 158 | + "- **Markdown cells** - These are used to build a nicely formatted narrative around the code in the document. The majority of this lesson is composed of markdown cells.\n", |
| 159 | + "\n", |
| 160 | + "- **Code cells** - These are used to define the computational code in the document. They come in two forms: the *input cell* where the user types the code to be executed, and the *output cell* which is the representation of the executed code. Depending on the code, this representation may be a simple scalar value, or something more complex like a plot or an interactive widget.\n", |
| 161 | + "\n", |
| 162 | + "- **Raw cells** - These are used when text needs to be included in raw form, without execution or transformation.\n", |
| 163 | + "\n", |
| 164 | + "This is what the three types of cells look like:\n", |
| 165 | + "\n", |
| 166 | + "<img src=\"images/cell_types.png\" />" |
| 167 | + ] |
| 168 | + }, |
| 169 | + { |
| 170 | + "cell_type": "markdown", |
| 171 | + "metadata": {}, |
| 172 | + "source": [ |
| 173 | + "#### Modality\n", |
| 174 | + "\n", |
| 175 | + "The notebook user interface is *modal*. This means that the keyboard behaves differently depending upon the current mode of the notebook. A notebook has two modes: **edit** and **command**.\n", |
| 176 | + "\n", |
| 177 | + "**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.\n", |
| 178 | + "\n", |
| 179 | + "<img src=\"images/edit_mode.png\">\n", |
| 180 | + "\n", |
| 181 | + "**Command mode** is indicated by a grey cell background. When in command mode, the structure of the notebook can be modified as a whole, but the text in individual cells cannot be changed. Most importantly, the keyboard is mapped to a set of shortcuts for efficiently performing notebook and cell actions. For example, pressing **`c`** when in command mode, will copy the current cell; no modifier is needed.\n", |
| 182 | + "\n", |
| 183 | + "<img src=\"images/command_mode.png\">\n", |
| 184 | + "\n", |
| 185 | + "Enter edit mode by pressing `Enter` or using the mouse to click on a cell's editor area.\n", |
| 186 | + "\n", |
| 187 | + "Enter command mode by pressing `Esc` or using the mouse to click *outside* a cell's editor area.\n", |
| 188 | + "\n", |
| 189 | + "Do not attempt to type into a cell when in command mode; unexpected things will happen!" |
| 190 | + ] |
| 191 | + }, |
| 192 | + { |
| 193 | + "cell_type": "markdown", |
| 194 | + "metadata": {}, |
| 195 | + "source": [ |
| 196 | + "#### Mouse navigation\n", |
| 197 | + "\n", |
| 198 | + "The first concept to understand in mouse-based navigation is that **cells can be selected by clicking on them.** The currently selected cell is indicated with a blue outline or gray background depending on whether the notebook is in edit or command mode. Clicking inside a cell's editor area will enter edit mode. Clicking on the prompt or the output area of a cell will enter command mode.\n", |
| 199 | + "\n", |
| 200 | + "The second concept to understand in mouse-based navigation is that **cell actions usually apply to the currently selected cell**. For example, to run the code in a cell, select it and then click the <button class='btn btn-default btn-xs'><i class=\"fa fa-play icon-play\"></i></button> button in the toolbar or the **`Run -> Run Selected Cells`** menu item. Similarly, to copy a cell, select it and then click the <button class='btn btn-default btn-xs'><i class=\"fa fa-copy icon-copy\"></i></button> button in the toolbar or the **`Edit -> Copy`** menu item. With this simple pattern, it should be possible to perform nearly every action with the mouse.\n", |
| 201 | + "\n", |
| 202 | + "Markdown cells have one other state which can be modified with the mouse. These cells can either be rendered or unrendered. When they are rendered, a nice formatted representation of the cell's contents will be presented. When they are unrendered, the raw text source of the cell will be presented. To render the selected cell with the mouse, click the <button class='btn btn-default btn-xs'><i class=\"fa fa-play icon-play\"></i></button> button in the toolbar or the **`Run -> Run Selected Cells`** menu item. To unrender the selected cell, double click on the cell." |
| 203 | + ] |
| 204 | + }, |
| 205 | + { |
| 206 | + "cell_type": "markdown", |
| 207 | + "metadata": {}, |
| 208 | + "source": [ |
| 209 | + "#### Keyboard Navigation\n", |
| 210 | + "\n", |
| 211 | + "The modal user interface of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n", |
| 212 | + "\n", |
| 213 | + "The most important keyboard shortcuts are **`Enter`**, which enters edit mode, and **`Esc`**, which enters command mode.\n", |
| 214 | + "\n", |
| 215 | + "In edit mode, most of the keyboard is dedicated to typing into the cell's editor. Thus, in edit mode there are relatively few shortcuts. In command mode, the entire keyboard is available for shortcuts, so there are many more possibilities.\n", |
| 216 | + "\n", |
| 217 | + "The following shortcuts have been found to be the most useful in day-to-day tasks:\n", |
| 218 | + "\n", |
| 219 | + "- Basic navigation: **`enter`**, **`shift-enter`**, **`up/k`**, **`down/j`**\n", |
| 220 | + "- Saving the notebook: **`s`**\n", |
| 221 | + "- Cell types: **`y`**, **`m`**, **`r`**\n", |
| 222 | + "- Cell creation: **`a`**, **`b`**\n", |
| 223 | + "- Cell editing: **`x`**, **`c`**, **`v`**, **`d`**, **`z`**, **`ctrl+shift+-`**\n", |
| 224 | + "- Kernel operations: **`i`**, **`.`**\n", |
| 225 | + "\n", |
| 226 | + "You can fully customize JupyterLab's keybindings by accessing the **`Settings -> Advanced Settings Editor`** menu item." |
| 227 | + ] |
| 228 | + }, |
159 | 229 | { |
160 | 230 | "cell_type": "markdown", |
161 | 231 | "metadata": {}, |
|
361 | 431 | "cell_type": "markdown", |
362 | 432 | "metadata": {}, |
363 | 433 | "source": [ |
364 | | - "All output is displayed asynchronously as it is generated in the Kernel. If you execute the next cell, you will see the output one piece at a time, not all at the end." |
| 434 | + "All output is displayed as it is generated in the Kernel: instead of blocking on the execution of the entire cell, output is made available to the Notebook immediately as it is generated by the kernel (even though the whole cell is submitted for execution as a single unit).\n", |
| 435 | + "\n", |
| 436 | + "If you execute the next cell, you will see the output one piece at a time, not all at the end:" |
365 | 437 | ] |
366 | 438 | }, |
367 | 439 | { |
|
0 commit comments