summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kolset <christian.kolset@gmail.com>2025-04-28 11:41:51 -0600
committerChristian Kolset <christian.kolset@gmail.com>2025-04-28 11:41:51 -0600
commitf1cc185b2571715b3077c9ea8ed601940a8f4932 (patch)
treeb2793dcc95f789ea43fcf406501a4680d46bc01f
parent8216a16d78d7aff5bc5a1607694ec3ea24eef64f (diff)
notebook files in module 1. Added content
-rw-r--r--tutorials/module_1/array.md20
-rw-r--r--tutorials/module_1/arrays.ipynb252
-rw-r--r--tutorials/module_1/fundamentals_of_programming.md2
-rw-r--r--tutorials/module_1/jupyter_lab_notebook.ipynb131
-rw-r--r--tutorials/module_1/jupyter_lab_notebook.md66
-rw-r--r--tutorials/module_1/notebook_1/fundamentals_of_programming.ipynb26
6 files changed, 389 insertions, 108 deletions
diff --git a/tutorials/module_1/array.md b/tutorials/module_1/array.md
index 449135a..3c0290e 100644
--- a/tutorials/module_1/array.md
+++ b/tutorials/module_1/array.md
@@ -118,27 +118,27 @@ Due to the nature of zero-based indexing. If we want to call the value `4.054973
## Exercise
Let's solve a statics problem given the following problem
-A simply supported bridge of length L=20L = 20L=20 m is subjected to three point loads:
+A simply supported bridge of length L = 20 m is subjected to three point loads:
-- $P1=10P_1 = 10P1​=10 kN$ at $x=5x = 5x=5 m$
-- $P2=15P_2 = 15P2​=15 kN$ at $x=10x = 10x=10 m$
-- $P3=20P_3 = 20P3​=20 kN$ at $x=15x = 15x=15 m$
+- $P_1 = 10 kN$ at $x = 5 m$
+- $P_2 = 15 kN$ at $x = 10 m$
+- $P_3 = 20 kN$ at $x = 15 m$
The bridge is supported by two reaction forces at points AAA (left support) and BBB (right support). We assume the bridge is in static equilibrium, meaning the sum of forces and sum of moments about any point must be zero.
##### Equilibrium Equations:
1. **Sum of Forces in the Vertical Direction**:
- $RA+RB−P1−P2−P3=0R_A + R_B - P_1 - P_2 - P_3 = 0RA​+RB​−P1​−P2​−P3​=0$
+ $R_A + R_B - P_1 - P_2 - P_3 = 0$
2. **Sum of Moments About Point A**:
- $5P1+10P2+15P3−20RB=05 P_1 + 10 P_2 + 15 P_3 - 20 R_B = 05P1​+10P2​+15P3​−20RB​=0$
+ $5 P_1 + 10 P_2 + 15 P_3 - 20 R_B = 0$
3. **Sum of Moments About Point B**:
- $20RA−15P3−10P2−5P1=020 R_A - 15 P_3 - 10 P_2 - 5 P_1 = 020RA​−15P3​−10P2​−5P1​=0$
+ $20 R_A - 15 P_3 - 10 P_2 - 5 P_1 = 0$
##### System of Equations:
-
-{RA+RB−10−15−20=05(10)+10(15)+15(20)−20RB=020RA−5(10)−10(15)−15(20)=0\begin{cases} R_A + R_B - 10 - 15 - 20 = 0 \\ 5(10) + 10(15) + 15(20) - 20 R_B = 0 \\ 20 R_A - 5(10) - 10(15) - 15(20) = 0 \end{cases}⎩
-
+$$
+\begin{cases} R_A + R_B - 10 - 15 - 20 = 0 \\ 5(10) + 10(15) + 15(20) - 20 R_B = 0 \\ 20 R_A - 5(10) - 10(15) - 15(20) = 0 \end{cases}
+$$
### Solution
```python
diff --git a/tutorials/module_1/arrays.ipynb b/tutorials/module_1/arrays.ipynb
index 7fe777d..f0ad435 100644
--- a/tutorials/module_1/arrays.ipynb
+++ b/tutorials/module_1/arrays.ipynb
@@ -2,10 +2,10 @@
"cells": [
{
"cell_type": "markdown",
- "id": "22b60740-09ee-4205-ab11-206bbef80709",
+ "id": "7caa19c6-3283-43a2-8730-711610242dc8",
"metadata": {},
"source": [
- "# matrixArrays\n",
+ "# Arrays\n",
"\n",
"In computer programming, an array is a structure for storing and retrieving data. We often talk about an array as if it were a grid in space, with each cell storing one element of the data. For instance, if each element of the data were a number, we might visualize a “one-dimensional” array like a list:\n",
"\n",
@@ -24,26 +24,48 @@
"- From [Numpy documentation](https://numpy.org/doc/2.2/user/absolute_beginners.html)\n",
"![Mathworks 3-D array](../figures/multi-dimensional-array.gif)\n",
"\n",
- "If the load on this block changes over time, then we may want to add a 4th dimension i.e. additional sets of 3-D arrays for each time increment. As you can see - the more dimensions we add, the more complicated of a problem we have to solve. It is possible to increase the number of dimensions to the n-th order. This course we will not be going beyond dimensional analysis.\n",
- "\n",
- "---\n",
- "\n",
+ "If the load on this block changes over time, then we may want to add a 4th dimension i.e. additional sets of 3-D arrays for each time increment. As you can see - the more dimensions we add, the more complicated of a problem we have to solve. It is possible to increase the number of dimensions to the n-th order. This course we will not be going beyond dimensional analysis."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "08cef772-93f4-4cd9-8d0e-746a2a9be4de",
+ "metadata": {},
+ "source": [
"# Numpy - the python's array library\n",
"\n",
"In this tutorial we will be introducing arrays and we will be using the numpy library. Arrays, lists, vectors, matrices, sets - You might've heard of them before, they all store data. In programming, an array is a variable that can hold more than one value at a time. We will be using the Numpy python library to create arrays. Since we already have installed Numpy previously, we can start using the package.\n",
"\n",
- "Before importing our first package, let's as ourselves *what is a package?* A package can be thought of as pre-written python code that we can re-use. This means the for every script that we write in python we need to tell it to use a certain package. We call this importing a package.\n",
+ "Before importing our first package, let's as ourselves *what is a package?* A package can be thought of as pre-written python code that we can re-use. This means the for every script that we write in python we need to tell it to use a certain package. We call this *importing* a package.\n",
"\n",
"## Importing Numpy\n",
- "When using packages in python, we need to let it know what package we will be using. This is called importing. To import numpy we need to declare it a the start of a script as follows:\n",
- "```python\n",
- "import numpy as np\n",
- "```\n",
+ "When using packages in python, we need to let it know what package we will be using. This is called importing. To import numpy we need to declare it a the start of a script as follows:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "8badcbc9-5cde-46d6-9508-7e6209761d0b",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "dfd1a02a-01f6-4ccb-b5bc-23a82dfe40ce",
+ "metadata": {},
+ "source": [
"- `import` - calls for a library to use, in our case it is Numpy.\n",
- "- `as` - gives the library an alias in your script. It's common convention in Python programming to make the code shorter and more readable. We will be using *np* as it's a standard using in many projects.\n",
- "\n",
- "---\n",
- "\n",
+ "- `as` - gives the library an alias in your script. It's common convention in Python programming to make the code shorter and more readable. We will be using *np* as it's a standard using in many projects."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "51c5a7f9-291f-4415-a986-9102238859e3",
+ "metadata": {},
+ "source": [
"# Creating arrays\n",
"Now that we have imported the library we can create a one dimensional array or *vector* with three elements.\n",
"```python\n",
@@ -51,16 +73,27 @@
"```\n",
"\n",
"\n",
- "To create a *matrix* we can nest the arrays to create a two dimensional array. This is done as follows.\n",
- "\n",
- "```python\n",
+ "To create a *matrix* we can nest the arrays to create a two dimensional array. This is done as follows."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "id": "44b9d41f-0acf-4820-9f47-371f14e4f6b8",
+ "metadata": {},
+ "outputs": [],
+ "source": [
"matrix = np.array([[1,2,3],\n",
"\t\t\t\t [4,5,6],\n",
- "\t\t\t\t [7,8,9]])\n",
- "```\n",
- "\n",
- "*Note: for every array we nest, we get a new dimension in our data structure.*\n",
- "\n"
+ "\t\t\t\t [7,8,9]])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "bbdea9cb-af6c-49d0-b530-da297ec18163",
+ "metadata": {},
+ "source": [
+ "*Note: for every array we nest, we get a new dimension in our data structure.*"
]
},
{
@@ -86,7 +119,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 5,
"id": "7f2bcfe9-6e3d-424d-a08f-520682b3bdb5",
"metadata": {},
"outputs": [
@@ -111,44 +144,125 @@
},
{
"cell_type": "markdown",
- "id": "715d8fcd-8c8c-4f72-a8bd-7e369eb916a8",
+ "id": "9dbcd4e9-506d-4119-88f6-3fe83fd6356e",
"metadata": {},
"source": [
"## Numpy array creation functions\n",
"Numpy comes with some built-in function that we can use to create arrays quickly. Here are a couple of functions that are commonly used in python.\n",
"\n",
"### np.arange\n",
- "The `np.arange()` function returns an array with evenly spaced values within a specified range. It is similar to the built-in `range()` function in Python but returns a Numpy array instead of a list. The parameters for this function are the start value (inclusive), the stop value (exclusive), and the step size. If the step size is not provided, it defaults to 1.\n",
- "\n",
- "```python\n",
- ">>> np.arange(4)\n",
- "array([0. , 1., 2., 3. ])\n",
- "```\n",
- "\n",
+ "The `np.arange()` function returns an array with evenly spaced values within a specified range. It is similar to the built-in `range()` function in Python but returns a Numpy array instead of a list. The parameters for this function are the start value (inclusive), the stop value (exclusive), and the step size. If the step size is not provided, it defaults to 1."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "dabff758-4003-4f64-bd9e-1a6c8d1f6b70",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([0, 1, 2, 3])"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "np.arange(4)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3a51ab81-1d38-425d-9f0e-e01b07632240",
+ "metadata": {},
+ "source": [
"In this example, `np.arange(4)` generates an array starting from 0 and ending before 4, with a step size of 1.\n",
"\n",
"### np.linspace\n",
- "The `np.linspace()` function returns an array of evenly spaced values over a specified range. Unlike `np.arange()`, which uses a step size to define the spacing between elements, `np.linspace()` uses the number of values you want to generate and calculates the spacing automatically. It accepts three parameters: the start value, the stop value, and the number of samples.\n",
- "\n",
- "```python\n",
- ">>> np.linspace(1., 4., 6)\n",
- "array([1. , 1.6, 2.2, 2.8, 3.4, 4. ])\n",
- "```\n",
- "\n",
+ "The `np.linspace()` function returns an array of evenly spaced values over a specified range. Unlike `np.arange()`, which uses a step size to define the spacing between elements, `np.linspace()` uses the number of values you want to generate and calculates the spacing automatically. It accepts three parameters: the start value, the stop value, and the number of samples."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "6ade3b6b-ea5c-4894-aff5-6e24ae43b9fe",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([1. , 1.6, 2.2, 2.8, 3.4, 4. ])"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "np.linspace(1., 4., 6)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "8ce82fb1-d843-4203-acc2-0ff3327ebd34",
+ "metadata": {},
+ "source": [
"In this example, `np.linspace(1., 4., 6)` generates 6 evenly spaced values between 1. and 4., including both endpoints.\n",
"\n",
- "Try this and see what happens:\n",
- "\n",
- "```python\n",
- "x = np.linspace(0,100,101)\n",
+ "Try this and see what happens:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "73b23a4a-3482-4b50-905c-92d0fe06acd9",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[ 0. 0.06235951 0.12447629 0.18610855 0.24701637 0.30696269\n",
+ " 0.36571416 0.42304208 0.47872332 0.53254113 0.58428602 0.63375658\n",
+ " 0.68076024 0.72511405 0.76664535 0.80519249 0.84060542 0.8727463\n",
+ " 0.90149002 0.92672468 0.94835208 0.96628801 0.98046268 0.9908209\n",
+ " 0.99732234 0.99994172 0.99866883 0.99350862 0.98448118 0.97162165\n",
+ " 0.95498009 0.93462127 0.91062444 0.88308301 0.85210418 0.81780853\n",
+ " 0.78032958 0.73981319 0.69641708 0.65031016 0.60167192 0.55069167\n",
+ " 0.49756786 0.44250727 0.38572421 0.32743973 0.26788069 0.20727893\n",
+ " 0.14587033 0.08389393 0.02159098 -0.04079602 -0.10302422 -0.1648514\n",
+ " -0.22603689 -0.28634254 -0.3455336 -0.40337967 -0.45965558 -0.51414229\n",
+ " -0.5666277 -0.61690752 -0.66478602 -0.71007685 -0.75260371 -0.79220105\n",
+ " -0.82871476 -0.8620027 -0.89193529 -0.91839603 -0.94128192 -0.96050387\n",
+ " -0.97598706 -0.98767123 -0.99551089 -0.99947552 -0.9995497 -0.99573314\n",
+ " -0.98804069 -0.97650229 -0.96116286 -0.94208211 -0.91933431 -0.893008\n",
+ " -0.86320566 -0.83004329 -0.79364999 -0.7541674 -0.71174922 -0.66656056\n",
+ " -0.61877731 -0.56858548 -0.51618043 -0.46176614 -0.40555444 -0.34776411\n",
+ " -0.28862012 -0.22835267 -0.16719636 -0.10538923 -0.04317189]\n"
+ ]
+ }
+ ],
+ "source": [
+ "x = np.linspace(0,6.24,101)\n",
"y = np.sin(x)\n",
- "```\n",
"\n",
+ "print(y)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "82fc9e4b-6aaf-4753-b988-4350eebbee0f",
+ "metadata": {},
+ "source": [
"### Other useful functions\n",
"- `np.zeros()`\n",
"- `np.ones()`\n",
- "- `np.eye()` \n",
- "\n"
+ "- `np.eye()` "
]
},
{
@@ -162,7 +276,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 8,
"id": "0c5de840-6256-4de2-9845-1c80a12c062d",
"metadata": {},
"outputs": [
@@ -181,7 +295,7 @@
},
{
"cell_type": "markdown",
- "id": "ae9aae08-b05b-4385-aa13-20dc1f8b88f2",
+ "id": "81c71011-1e20-413f-be61-9ef07a8d022a",
"metadata": {},
"source": [
"## Working with Arrays\n",
@@ -192,14 +306,37 @@
"\n",
"Python uses **zero-based indexing**, meaning the first element is at position **0** rather than **1**. This approach is common in many programming languages. For example, in a list with five elements, the first element is at index `0`, followed by elements at indices `1`, `2`, `3`, and `4`.\n",
"\n",
- "Here's an example of data from a rocket test stand where thrust was recorded as a function of time.\n",
- "\n",
- "```python\n",
- "thrust_lbf = np.array(0.603355, 2.019083, 2.808092, 4.054973, 1.136618, 0.943668)\n",
- "\n",
- ">>> thrust_lbs[3]\n",
- "```\n",
+ "Here's an example of data from a rocket test stand where thrust was recorded as a function of time."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "bc405b0a-9914-400c-9fcf-f81ba058bed9",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "np.float64(4.054973)"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "thrust_lbf = np.array([0.603355, 2.019083, 2.808092, 4.054973, 1.136618, 0.943668])\n",
"\n",
+ "thrust_lbf[3]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d621cef0-440b-453d-b3a5-7ad6f1eca0e1",
+ "metadata": {},
+ "source": [
"Due to the nature of zero-based indexing. If we want to call the value `4.054973` that will be the 3rd index. \n",
"\n",
"### Operations on arrays\n",
@@ -217,8 +354,7 @@
"#### Combining arrays\n",
"- Concatenation: `np.concatenate((arr1, arr2), axis=0)`\n",
"- Stacking: `np.vstack()`, `np.hstack()`\n",
- "- Splitting: `np.split()`\n",
- "\n"
+ "- Splitting: `np.split()`"
]
},
{
@@ -266,7 +402,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 5,
"id": "fc0244f6-d7f2-499a-a929-7f080d981b3e",
"metadata": {},
"outputs": [
diff --git a/tutorials/module_1/fundamentals_of_programming.md b/tutorials/module_1/fundamentals_of_programming.md
index 617d2c3..a5577af 100644
--- a/tutorials/module_1/fundamentals_of_programming.md
+++ b/tutorials/module_1/fundamentals_of_programming.md
@@ -9,7 +9,5 @@ This is a text based interface that allows the users to interact with the comput
### Text Editor / Script
Your text editor is the program used to write a script which can be re-run every time you call it from the command window. This can be a built-in text editor such as Spyder and MATLAB provide or an external on such a notepad++.
-
-
Globe analogy: Hardware, Kernel, shell, Application software.
- Scripting \ No newline at end of file
diff --git a/tutorials/module_1/jupyter_lab_notebook.ipynb b/tutorials/module_1/jupyter_lab_notebook.ipynb
new file mode 100644
index 0000000..20b297c
--- /dev/null
+++ b/tutorials/module_1/jupyter_lab_notebook.ipynb
@@ -0,0 +1,131 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "3895c65a-b923-4c86-94a4-a43dfb09eeab",
+ "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",
+ "- Creating a new notebook (`.ipynb`)\n",
+ "- Types of cells:\n",
+ " - Code\n",
+ " - Markdown\n",
+ " - Raw\n",
+ "- Running a cell: `Shift + Enter`\n",
+ "- Adding/removing cells\n",
+ "- Restarting the kernel\n",
+ "- Saving and auto-checkpoints\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",
+ "## Writing and Running Code\n",
+ "\n",
+ "- Python syntax: - `print(\"Hello, world!\")` - Variables and\n",
+ " functions - Loops and conditionals\n",
+ "- Importing libraries: - `import numpy as np` -\n",
+ " `import pandas as pd` - `import matplotlib.pyplot as plt`\n",
+ "\n",
+ "## Using Markdown\n",
+ "\n",
+ "- Headers: `#`, `##`, `###`\n",
+ "- Bullet lists: `- item`\n",
+ "- Numbered lists: `1. item`\n",
+ "- Emphasis: *italic*, **bold**, `monospace`\n",
+ "- LaTeX equations:\n",
+ " - Inline: `$E = mc^2$`\n",
+ " - Block: `$$\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}$$`\n",
+ "- Embedding links and images\n",
+ "\n",
+ "## Interactive Widgets (optional)\n",
+ "\n",
+ "Install `ipywidgets` from your package manager\n",
+ "\n",
+ "``` python\n",
+ "import ipywidgets as widgets\n",
+ "widgets.IntSlider()\n",
+ "```\n",
+ "\n",
+ "Example using interact:\n",
+ "\n",
+ "``` python\n",
+ "from ipywidgets import interact\n",
+ "interact(lambda x: x**2, x=5)\n",
+ "```\n",
+ "\n",
+ "## Productivity Tips\n",
+ "\n",
+ "Here are some keyboard shortcuts to improve your productivity when\n",
+ "writing in notebooks.\n",
+ "\n",
+ "| Key | Action |\n",
+ "|-----|--------------------|\n",
+ "| A | insert cell above |\n",
+ "| B | insert cell below |\n",
+ "| M | switch to Markdown |\n",
+ "| Y | switch to code |\n",
+ "\n",
+ "Magic commands: - `%timeit`, `%matplotlib inline`, `%%bash` Splitting\n",
+ "and merging cells Auto-save behavior\n",
+ "\n",
+ "## Exporting and Sharing\n",
+ "\n",
+ "- File \\> Download As:\n",
+ " - Notebook (`.ipynb`)\n",
+ " - HTML\n",
+ " - PDF (requires LaTeX)\n",
+ " - Markdown\n",
+ "- Notebooks can be saved and shared via the following services: -\n",
+ " GitHub - nbviewer.org - mybinder.org - JupyterHub"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "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.13.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/tutorials/module_1/jupyter_lab_notebook.md b/tutorials/module_1/jupyter_lab_notebook.md
index 14d9236..f9b3393 100644
--- a/tutorials/module_1/jupyter_lab_notebook.md
+++ b/tutorials/module_1/jupyter_lab_notebook.md
@@ -7,16 +7,9 @@ Jupyter Notebooks are often used for data science and scientific computing such
## Setup and Installation
-Installing with Conda using CLI:
-- `conda install jupyter`
-Jupyter can also be installed using a Anaconda Navigator
+Jupyter Notebooks can be installed either from the Anaconda Navigator home page or directly from your Conda terminal.
- - Launching:
- - From terminal: `jupyter notebook` or `jupyter lab`
- - From Anaconda Navigator or VSCode
- - Navigating the interface:
- - Tabs and file browser
- - Kernel and terminals
+Terminal: `conda install conda-forge::jupyterlab`
## Notebook Basics
- Creating a new notebook (`.ipynb`)
@@ -29,6 +22,29 @@ Jupyter can also be installed using a Anaconda Navigator
- Restarting the kernel
- Saving and auto-checkpoints
+Jupyter Notebooks are files which allows you to combine *Code* and *Markdown* cells in one single document. The code cells, allow you to interactively run python code and print and plot data in your document. If you wish to update or change data your code you can re-run the cell to update the output. The markdown cells allows you to write text, titles and insert images in your documentation using the markup language *Markdown*.
+
+To start a new notebook select `File > New > Notebook` or right click the file browser and select `New notebook`, this will prompt you to select a kernel (the Jupyter notebook "engine"). For now, just select the default Kernel 3. This will start a new fresh kernel for us to use. Next, it's recommended to rename the file.
+
+Now that we have a blank notebook we can start to add cells. Add a cell and change the type to Markdown. Add a title with the hash symbol (`#`). As shown below.
+
+```markdown
+# Title here
+```
+Press `Shift + Enter` to run the cell. You just entered created your first markdown cell.
+Now let's do the same but instead select code as the cell type, we're going to add some python code to the document.
+```python
+x = 4
+y = 3
+
+x**2+2*y
+```
+Again, run the cell and see what happens. You should've gotten an output of `22`. You can now use the notebook as a calculator, but there is so much more we can do.
+
+The order of running code matters. Think of the code cells as code snippets. Every time you run a cell variable will be updated. This means that the current state of all variables, functions, and imports depends on the history of what cells have been executed and in what order. In other words, if you run a later cell before running an earlier one that defines a variable or function it needs, you will get an error. If you change a variable in one cell and rerun it, that new value immediately 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. Therefore, let's press the `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 (`Kernel -> Restart & Run All`) to make sure everything works cleanly and predictably and lastly, initialize important variables or imports in early cells, so they are always defined before they are needed.
+
## Writing and Running Code
- Python syntax:
- `print("Hello, world!")`
@@ -65,29 +81,11 @@ from ipywidgets import interact
interact(lambda x: x**2, x=5)
```
-
-## Productivity Tips
-Here are some keyboard shortcuts to improve your productivity when writing in notebooks.
-
-| Key | Action |
-| --- | ------------------ |
-| A | insert cell above |
-| B | insert cell below |
-| M | switch to Markdown |
-| Y | switch to code |
- Magic commands:
-- `%timeit`, `%matplotlib inline`, `%%bash`
-Splitting and merging cells
-Auto-save behavior
-
## Exporting and Sharing
- - File > Download As:
- - Notebook (`.ipynb`)
- - HTML
- - PDF (requires LaTeX)
- - Markdown
-- Notebooks can be saved and shared via the following services:
- - GitHub
- - nbviewer.org
- - mybinder.org
- - JupyterHub \ No newline at end of file
+By default, jupyter auto-saves your notebooks as you work.
+
+- File > Download As:
+ - Notebook (`.ipynb`)
+ - HTML
+ - PDF (requires LaTeX)
+ - Markdown
diff --git a/tutorials/module_1/notebook_1/fundamentals_of_programming.ipynb b/tutorials/module_1/notebook_1/fundamentals_of_programming.ipynb
index 79240a7..963ee18 100644
--- a/tutorials/module_1/notebook_1/fundamentals_of_programming.ipynb
+++ b/tutorials/module_1/notebook_1/fundamentals_of_programming.ipynb
@@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
+ "id": "a283b045-32a1-410b-a754-ad14dd955347",
"metadata": {},
"source": [
"# Fundamentals of programming\n",
@@ -25,11 +26,28 @@
"\n",
" Globe analogy: Hardware, Kernel, shell, Application software.\n",
" - Scripting"
- ],
- "id": "a283b045-32a1-410b-a754-ad14dd955347"
+ ]
}
],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "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.13.2"
+ }
+ },
"nbformat": 4,
- "nbformat_minor": 5,
- "metadata": {}
+ "nbformat_minor": 5
}