{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "\n", "In this notebook, we cover some basics on Jupyter and its usage.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction and Links\n", "\n", "[Jupyter](http://jupyter.org/) is a non-profit, open-source project, born out of the IPython project. It exists to develop open-source software, open-standards, and services for interactive computing across dozens of programming languages. The Jupyter notebook framework allows for keeping code, images, comments, formulas and plots together. Here are some further links:\n", "\n", "* For details we refer to the [Jupyter Notebook QuickStart](http://jupyter.readthedocs.io/en/latest/content-quickstart.html).\n", "* Some more advanced hints can be found ad the post [28 Jupyter Notebook tips, tricks, and shortcuts](https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/).\n", "* To start the notebook server from the command line, use the command `jupyter notebook`. This opens the default web browser at the URL `http://localhost:8888`\n", "* You may configure jupyter notebook in various ways. For example, to disable cross-site-request-forgery protection (allowing remote content to be shown) you may use the command` and ``\n", "\n", "* Instead of the `
` element, one can use the grave accent (`` ` ``) to indicate a `code fragment`\n",
"\n",
"\n",
"1. Ordered (numbered) lists use regular numbers, followed by periods, as list markers.\n",
"2. This is an example of a numbered list.\n",
"3. Inline-style links use parentheses immediately after the link text. \n",
" This is an example for a [link](http://www.music-processing.de)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Keyboard Shortcuts \n",
"\n",
"Keyboard shortcuts save lots of time. To access these shortcuts, note that Jupyter notebook operates in two modes:\n",
"\n",
"* In the **edit mode** (indicated by a green cell border) one can type into the cell in the usual way. \n",
"* In the **command mode** (indicated by a gray cell border with a blue left margin) one is able to edit the notebook using keyboard shortcuts. \n",
"\n",
"To enter the command mode, one can either press `Esc` or use the mouse to click outside a cell's editor area. Being in command mode, one can use the following keyboard shortcuts:\n",
"\n",
"* `Esc`: switch to command mode\n",
"* `H`: access help menue with keyboard shortcuts\n",
"* `P`: open the command palette\n",
"* `Ctrl + Enter`: run selected cells\n",
"* `Shift + Enter`: run cell, select below\n",
"* `A`: insert a new cell above current cell\n",
"* `B`: insert a new cell below current cell\n",
"* `Ctrl + Shift + -`: split cell at current cursor position\n",
"* `Y`: change cell to code\n",
"* `M`: change cell to markdown\n",
"* `D + D` (press the key twice): delete current cell\n",
"* `Z`: undo cell deletion\n",
"* `Shift + J` or `Shift + Down`: select cells downwards \n",
" `Shift + K` or `Shift + Up`: select cells upwards \n",
" Once cells are selected, one can delete/copy/cut/paste/run them as a batch.\n",
"* `Shift + M`: merge selected cells\n",
"* `X`: cut selected cells\n",
"* `C`: copy selected cells\n",
"* `V`: paste cells below\n",
"\n",
"\n",
"#### Copy multiple cells from one notebook to another\n",
"\n",
"* Select Cell and press `Esc` to go to command mode\n",
"* Hit `Shift + Up` or `Shift + Down` to select multiple cells\n",
"* Copy with `Ctrl + C`\n",
"* Paste with `Ctrl + V` (also possible in different notebook, make sure to be in command mode)\n",
"* You maybe asked to repeat `Ctrl + V`\n",
"\n",
"#### Column editing for text cells in edit mode\n",
"\n",
"* Press `Alt` button and keep holding it. The cursor should change its shape into a big plus sign.\n",
"* Using the mouse, point to the beginning of the first line and while holding the `Alt` button and pull down the mouse until the last line.\n",
"* Release the `Alt` button and edit in the column mode. \n",
"* For example, use the `#` character to comment multiple lines."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Accessing the Python Help Function\n",
"\n",
"There is an easy way within a Jupyter notebook session to call help for a Python function in order to see the function arguments. Being in a code cell, just place the cursor on the Python function in question and press `shift-Tab`. If you press `shift-Tab` several times, the entire documentation string is opened. For example, in the case of the built-in function `max`, this is equivalent to `help(max)` or ` print(max.__doc__)`."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2024-02-15T09:02:08.569042Z",
"iopub.status.busy": "2024-02-15T09:02:08.568749Z",
"iopub.status.idle": "2024-02-15T09:02:08.573598Z",
"shell.execute_reply": "2024-02-15T09:02:08.572848Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n",
"Help on built-in function max in module builtins:\n",
"\n",
"max(...)\n",
" max(iterable, *[, default=obj, key=func]) -> value\n",
" max(arg1, arg2, *args, *[, key=func]) -> value\n",
" \n",
" With a single iterable argument, return its biggest item. The\n",
" default keyword-only argument specifies an object to return if\n",
" the provided iterable is empty.\n",
" With two or more arguments, return the largest argument.\n",
"\n"
]
}
],
"source": [
"print(max(2, 3, 4, 5))\n",
"# Placing cursor on function name 'max' and press shift-Tab. \n",
"# Then you obtain the information as with help(max).\n",
"help(max)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Further Notes\n",
" \n",
"- Sometimes the HTML export of a notebook looks different to how the notebook looks within Jupyer. This is a known (and yet unsolved) [issue in Jupyter](https://github.com/jupyter/help/issues/283). \n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"Acknowledgment: This notebook was created by Frank Zalkow and Meinard Müller.\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
}
},
"nbformat": 4,
"nbformat_minor": 1
}