diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2025-04-11 14:19:25 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2025-04-11 14:19:25 -0600 |
| commit | 5bd32145a44d859dbc5981a808ca35938ff3917e (patch) | |
| tree | f95cc63af7c2836f30d8f654302d2d149dbf0b85 | |
| parent | adc96aa6fa23d757aaf7a3d79233d3497a7cd511 (diff) | |
Added changes from Dr. D to explain how the tutorial will be taught in lecture.
| -rw-r--r-- | tutorials/module_1/arrays.ipynb | 121 |
1 files changed, 116 insertions, 5 deletions
diff --git a/tutorials/module_1/arrays.ipynb b/tutorials/module_1/arrays.ipynb index 0a2afc2..efb14bb 100644 --- a/tutorials/module_1/arrays.ipynb +++ b/tutorials/module_1/arrays.ipynb @@ -5,7 +5,7 @@ "id": "22b60740-09ee-4205-ab11-206bbef80709", "metadata": {}, "source": [ - "# Arrays\n", + "# matrixArrays\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", @@ -58,7 +58,59 @@ "```\n", "\n", "*Note: for every array we nest, we get a new dimension in our data structure.*\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "0dec9d37-266d-42a5-9ad4-9f8a17548be7", + "metadata": {}, + "source": [ + "# Display arrays\n", "\n", + "Using command print(\"\") \n", + "Accessing particular elements of an array ....." + ] + }, + { + "cell_type": "markdown", + "id": "bfe1e32c-9fcb-4dc2-a948-b070e36938ab", + "metadata": {}, + "source": [ + "# Practice Problem\n", + "Problem statement" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "7f2bcfe9-6e3d-424d-a08f-520682b3bdb5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[ 7 10 12]\n", + "10\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "x = np.array([7, 10 ,12])\n", + "\n", + "print(x)\n", + "\n", + "print(x[1])" + ] + }, + { + "cell_type": "markdown", + "id": "715d8fcd-8c8c-4f72-a8bd-7e369eb916a8", + "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", "### np.arange\n", @@ -92,7 +144,42 @@ "- `np.zeros()`\n", "- `np.ones()`\n", "- `np.eye()` \n", - "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "e7c7fe0b-1dac-48bb-83e5-5a71cc11570b", + "metadata": {}, + "source": [ + "## Practice problem\n", + "Problem statement below" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "0c5de840-6256-4de2-9845-1c80a12c062d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[10. 12.5 15. 17.5 20. ]\n" + ] + } + ], + "source": [ + "y=np.linspace(10,20,5)\n", + "print(y)" + ] + }, + { + "cell_type": "markdown", + "id": "ae9aae08-b05b-4385-aa13-20dc1f8b88f2", + "metadata": {}, + "source": [ "## Working with Arrays\n", "Now that we have been introduced to some ways to create arrays using the Numpy functions let's start using them.\n", "### Indexing\n", @@ -123,7 +210,31 @@ "- Concatenation: `np.concatenate((arr1, arr2), axis=0)`\n", "- Stacking: `np.vstack()`, `np.hstack()`\n", "- Splitting: `np.split()`\n", - "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "b1194250-2861-4001-899c-ced19f0f34ee", + "metadata": {}, + "source": [ + "## Practice problem\n", + "Problem statement here" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "777186e0-f734-4bc4-93f0-6746b428f821", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "id": "29f020bf-b714-49a7-96bf-4e20138c7722", + "metadata": {}, + "source": [ "# Exercise\n", "Let's solve a statics problem given the following problem\n", "\n", @@ -179,7 +290,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7f2bcfe9-6e3d-424d-a08f-520682b3bdb5", + "id": "5c20b2fd-d9ce-49fa-b2d7-259e5b121bc7", "metadata": {}, "outputs": [], "source": [] @@ -201,7 +312,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.2" + "version": "3.12.9" } }, "nbformat": 4, |
