summaryrefslogtreecommitdiff
path: root/tutorials/module_1/notebook_1/jupyter_lab_notebook.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/module_1/notebook_1/jupyter_lab_notebook.ipynb')
-rw-r--r--tutorials/module_1/notebook_1/jupyter_lab_notebook.ipynb138
1 files changed, 138 insertions, 0 deletions
diff --git a/tutorials/module_1/notebook_1/jupyter_lab_notebook.ipynb b/tutorials/module_1/notebook_1/jupyter_lab_notebook.ipynb
new file mode 100644
index 0000000..2c00bd0
--- /dev/null
+++ b/tutorials/module_1/notebook_1/jupyter_lab_notebook.ipynb
@@ -0,0 +1,138 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Introduction\n",
+ "\n",
+ "Jupyter Notebooks are often used for data science and scientific\n",
+ "computing such as machine learning as the interactive design allow you\n",
+ "to experiment easily with your code. For our purpose, we will use\n",
+ "Notebooks as it’s a useful tool to learn how to code as well as writing\n",
+ "reports.\n",
+ "\n",
+ "*Note on the difference between Notebook and Lab: Jupyter Notebook\n",
+ "offers a simplified, lightweight notebook authoring experience, where\n",
+ "as, JupyterLab offers a feature-rich, tabbed multi-notebook editing\n",
+ "environment with additional tools like a customizable interface layout\n",
+ "and system console*\n",
+ "\n",
+ "## Setup and Installation\n",
+ "\n",
+ "Jupyter Notebooks can be installed either from the Anaconda Navigator\n",
+ "home page or directly from your Conda terminal.\n",
+ "\n",
+ "Terminal: `conda install conda-forge::jupyterlab`\n",
+ "\n",
+ "## Notebook Basics\n",
+ "\n",
+ "Jupyter Notebooks are files which allows you to combine *Code* and\n",
+ "*Markdown* cells in one single document. The code cells, allow you to\n",
+ "interactively run python code and print and plot data in your document.\n",
+ "If you wish to update or change data your code you can re-run the cell\n",
+ "to update the output. The markdown cells allows you to write text,\n",
+ "titles and insert images in your documentation using the markup language\n",
+ "*Markdown*.\n",
+ "\n",
+ "To start a new notebook select `File > New > Notebook` or right click\n",
+ "the file browser and select `New notebook`, this will prompt you to\n",
+ "select a kernel (the Jupyter notebook “engine”). For now, just select\n",
+ "the default Kernel 3. This will start a new fresh kernel for us to use.\n",
+ "Next, it’s recommended to rename the file.\n",
+ "\n",
+ "Now that we have a blank notebook we can start to add cells. Add a cell\n",
+ "and change the type to Markdown. Add a title with the hash symbol (`#`).\n",
+ "As shown below.\n",
+ "\n",
+ "``` markdown\n",
+ "# Title here\n",
+ "```\n",
+ "\n",
+ "Press `Shift + Enter` to run the cell. You just entered created your\n",
+ "first markdown cell. Now let’s do the same but instead select code as\n",
+ "the cell type, we’re going to add some python code to the document.\n",
+ "\n",
+ "``` python\n",
+ "x = 4\n",
+ "y = 3\n",
+ "\n",
+ "x**2+2*y\n",
+ "```\n",
+ "\n",
+ "Again, run the cell and see what happens. You should’ve gotten an output\n",
+ "of `22`. You can now use the notebook as a calculator, but there is so\n",
+ "much more we can do.\n",
+ "\n",
+ "The order of running code matters. Think of the code cells as code\n",
+ "snippets. Every time you run a cell variable will be updated. This means\n",
+ "that the current state of all variables, functions, and imports depends\n",
+ "on the history of what cells have been executed and in what order. In\n",
+ "other words, if you run a later cell before running an earlier one that\n",
+ "defines a variable or function it needs, you will get an error. If you\n",
+ "change a variable in one cell and rerun it, that new value immediately\n",
+ "affects the results of any cells that use that variable afterward — but\n",
+ "not any previously run results unless you rerun them too. Variables and\n",
+ "imports persist in memory between cells, but only based on the current\n",
+ "session state — if you restart the kernel, you lose all previous\n",
+ "definitions unless you re-run the necessary cells. Therefore, let’s\n",
+ "press the `Restart the kernel` button on the top window.3\n",
+ "\n",
+ "Because of this, it’s best practice to; Run cells in order, restart the\n",
+ "kernel and run all cells (`Kernel -> Restart & Run All`) to make sure\n",
+ "everything works cleanly and predictably and lastly, initialize\n",
+ "important variables or imports in early cells, so they are always\n",
+ "defined before they are needed.\n",
+ "\n",
+ "## Making your document look good with Markdown\n",
+ "\n",
+ "Creating titles or headers is done with the hash symbol. The number of\n",
+ "hashes determines whether it’s a sub-title `#`, `##`, `###`\n",
+ "\n",
+ "### Lists\n",
+ "\n",
+ "There are two types of list in - Bullet lists: `- item` - Numbered\n",
+ "lists: `1. item` \\### Style - Emphasis: *italic*, **bold**, `monospace`\n",
+ "\n",
+ "### Mathematical Equation\n",
+ "\n",
+ "Markdown supports LaTeX format equations. Inline equation is opened and\n",
+ "closed with a single `$`. For a block math a double `$$` is used instead\n",
+ "of single.\n",
+ "\n",
+ "- Inline: This equation is inline `$E = mc^2$` in with the markdown\n",
+ " text.\n",
+ "- Block: Whilst this is a block:\n",
+ " `$$\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}$$`\n",
+ "\n",
+ "### Links and images\n",
+ "\n",
+ "You can insert links to a different local file or online urls like this:\n",
+ "\\[Link\\](file.md). I insert an image it’s the same however start with an\n",
+ "exclamation mark `!` like this: \\![Image Caption\\](picture.png)\n",
+ "\n",
+ "## Exporting and Sharing\n",
+ "\n",
+ "To export your notebook go to\n",
+ "\n",
+ "`File` \\> `Download As`\n",
+ "\n",
+ "You can then select these options.\n",
+ "\n",
+ "- Notebook (`.ipynb`)\n",
+ "- HTML\n",
+ "- PDF (requires LaTeX)\n",
+ "- Markdown\n",
+ "\n",
+ "For homework assignments, download an HTML version of your document,\n",
+ "then from your browser, save or print as a PDF. Alternatively, you can\n",
+ "install the LaTeX typesetting system and export your document directly\n",
+ "as PDF from jupyter."
+ ],
+ "id": "0a5caa39-8f07-4d57-ad69-dc7470ed07ac"
+ }
+ ],
+ "nbformat": 4,
+ "nbformat_minor": 5,
+ "metadata": {}
+}