diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2025-04-29 18:38:21 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2025-04-29 18:38:21 -0600 |
| commit | dc13208abd61cc3ac7c64a4373f3ad85689f1293 (patch) | |
| tree | b8775c75daefe5c5f183b7fbb561b6d18e82f0d3 /book/module1/jupyter_lab_notebook.tex | |
| parent | ce478a33e25759b901d401609175713a5ded3522 (diff) | |
Finished of module 1 tutorials (.md) and added documentation to module 2
Diffstat (limited to 'book/module1/jupyter_lab_notebook.tex')
| -rw-r--r-- | book/module1/jupyter_lab_notebook.tex | 131 |
1 files changed, 39 insertions, 92 deletions
diff --git a/book/module1/jupyter_lab_notebook.tex b/book/module1/jupyter_lab_notebook.tex index 5c06f5d..c08fd74 100644 --- a/book/module1/jupyter_lab_notebook.tex +++ b/book/module1/jupyter_lab_notebook.tex @@ -21,32 +21,6 @@ Terminal: \texttt{conda\ install\ conda-forge::jupyterlab} \subsection{Notebook Basics}\label{notebook-basics} -\begin{itemize} -\tightlist -\item - Creating a new notebook (\texttt{.ipynb}) -\item - Types of cells: - - \begin{itemize} - \tightlist - \item - Code - \item - Markdown - \item - Raw - \end{itemize} -\item - Running a cell: \texttt{Shift\ +\ Enter} -\item - Adding/removing cells -\item - Restarting the kernel -\item - Saving and auto-checkpoints -\end{itemize} - Jupyter Notebooks are files which allows you to combine \emph{Code} and \emph{Markdown} cells in one single document. The code cells, allow you to interactively run python code and print and plot data in your @@ -100,7 +74,8 @@ affects the results of any cells that use that variable afterward --- but not any previously run results unless you rerun them too. Variables and imports persist in memory between cells, but only based on the current session state --- if you restart the kernel, you lose all -previous definitions unless you re-run the necessary cells. +previous definitions unless you re-run the necessary cells. Therefore, +let's press the \texttt{Restart\ the\ kernel} button on the top window.3 Because of this, it's best practice to; Run cells in order, restart the kernel and run all cells @@ -109,85 +84,57 @@ everything works cleanly and predictably and lastly, initialize important variables or imports in early cells, so they are always defined before they are needed. -\subsection{Writing and Running Code}\label{writing-and-running-code} +\subsection{Making your document look good with +Markdown}\label{making-your-document-look-good-with-markdown} -\begin{itemize} -\tightlist -\item - Python syntax: - \texttt{print("Hello,\ world!")} - Variables and - functions - Loops and conditionals -\item - Importing libraries: - \texttt{import\ numpy\ as\ np} - - \texttt{import\ pandas\ as\ pd} - - \texttt{import\ matplotlib.pyplot\ as\ plt} -\end{itemize} +Creating titles or headers is done with the hash symbol. The number of +hashes determines whether it's a sub-title \texttt{\#}, \texttt{\#\#}, +\texttt{\#\#\#} -\subsection{Using Markdown}\label{using-markdown} +\subsubsection{Lists}\label{lists} + +There are two types of list in - Bullet lists: \texttt{-\ item} - +Numbered lists: \texttt{1.\ item} \#\#\# Style - Emphasis: +\emph{italic}, \textbf{bold}, \texttt{monospace} \#\#\# Mathematical +Equation Markdown supports LaTeX format equations. Inline equation is +opened and closed with a single \texttt{\$}. For a block math a double +\texttt{\$\$} is used instead of single. \begin{itemize} \tightlist \item - Headers: \texttt{\#}, \texttt{\#\#}, \texttt{\#\#\#} -\item - Bullet lists: \texttt{-\ item} -\item - Numbered lists: \texttt{1.\ item} -\item - Emphasis: \emph{italic}, \textbf{bold}, \texttt{monospace} + Inline: This equation is inline \texttt{\$E\ =\ mc\^{}2\$} in with the + markdown text. \item - LaTeX equations: - - \begin{itemize} - \tightlist - \item - Inline: \texttt{\$E\ =\ mc\^{}2\$} - \item - Block: - \texttt{\$\$\textbackslash{}int\_0\^{}\textbackslash{}infty\ e\^{}\{-x\^{}2\}\ dx\ =\ \textbackslash{}frac\{\textbackslash{}sqrt\{\textbackslash{}pi\}\}\{2\}\$\$} - \end{itemize} -\item - Embedding links and images + Block: Whilst this is a block: + \texttt{\$\$\textbackslash{}int\_0\^{}\textbackslash{}infty\ e\^{}\{-x\^{}2\}\ dx\ =\ \textbackslash{}frac\{\textbackslash{}sqrt\{\textbackslash{}pi\}\}\{2\}\$\$} + \#\#\# Links and images You can insert links to a different local file + or online urls like this: {[}Link{]}(file.md). I insert an image it's + the same however start with an exclamation mark \texttt{!} like this: + !{[}Image Caption{]}(picture.png) \end{itemize} -\subsection{Interactive Widgets -(optional)}\label{interactive-widgets-optional} - -Install \texttt{ipywidgets} from your package manager - -\begin{Shaded} -\begin{Highlighting}[] -\ImportTok{import}\NormalTok{ ipywidgets }\ImportTok{as}\NormalTok{ widgets} -\NormalTok{widgets.IntSlider()} -\end{Highlighting} -\end{Shaded} - -Example using interact: +\subsection{Exporting and Sharing}\label{exporting-and-sharing} -\begin{Shaded} -\begin{Highlighting}[] -\ImportTok{from}\NormalTok{ ipywidgets }\ImportTok{import}\NormalTok{ interact} -\NormalTok{interact(}\KeywordTok{lambda}\NormalTok{ x: x}\OperatorTok{**}\DecValTok{2}\NormalTok{, x}\OperatorTok{=}\DecValTok{5}\NormalTok{)} -\end{Highlighting} -\end{Shaded} +To export your notebook go to -\subsection{Exporting and Sharing}\label{exporting-and-sharing} +\texttt{File} \textgreater{} \texttt{Download\ As} -By default, jupyter auto-saves your notebooks as you work. +You can then select these options. \begin{itemize} \tightlist \item - File \textgreater{} Download As: - - \begin{itemize} - \tightlist - \item - Notebook (\texttt{.ipynb}) - \item - HTML - \item - PDF (requires LaTeX) - \item - Markdown - \end{itemize} + Notebook (\texttt{.ipynb}) +\item + HTML +\item + PDF (requires LaTeX) +\item + Markdown \end{itemize} + +For homework assignments, download an HTML version of your document, +then from your browser, save or print as a PDF. Alternatively, you can +install the LaTeX typesetting system and export your document directly +as PDF from jupyter. |
