From 8801aeb4a863cbd40cb78e247c35a1e5af6a4de0 Mon Sep 17 00:00:00 2001 From: carolinevancalcar Date: Wed, 1 Oct 2025 13:30:31 +0200 Subject: [PATCH] Create new chapter for Debugging and shift the chapter numbering afterwards --- book/_toc.yml | 31 +- .../exercise_notebook_3_loops_debugging.zip | Bin 1891 -> 0 bytes ...exercise_notebook_3_structures_loops.ipynb | 2 +- ...otebook_3_structures_loops_debugging.ipynb | 363 ++---------------- ..._notebook_3_structures_loops_debugging.zip | Bin 4413 -> 1891 bytes ...nb => exercise_notebook_4_debugging.ipynb} | 49 ++- ...pynb => exercise_notebook_5_figures.ipynb} | 20 +- ...es.zip => exercise_notebook_5_figures.zip} | Bin ....ipynb => exercise_notebook_6_numpy.ipynb} | 6 +- ...umpy.zip => exercise_notebook_6_numpy.zip} | Bin ....ipynb => exercise_notebook_7_files.ipynb} | 0 ...iles.zip => exercise_notebook_7_files.zip} | Bin .../PythonNotebook3_data_structures.ipynb | 0 .../PythonNotebook3_first_page.ipynb | 4 +- .../PythonNotebook3_loops.ipynb | 0 .../PythonNotebook3_original.ipynb | 0 .../PythonNotebook4_debugging.ipynb} | 2 +- .../PythonNotebook4_first_page copy.ipynb | 76 ++++ .../PythonNotebook5_first_page.ipynb | 2 +- .../PythonNotebook5_matplotlib.ipynb | 18 +- .../PythonNotebook6_first_page.ipynb} | 2 +- .../PythonNotebook6_loading_data.ipynb} | 4 +- .../PythonNotebook6_original.ipynb} | 0 ...ok6_vectors_and_plotting_with_numpy.ipynb} | 6 +- .../PythonNotebook7_first_page.ipynb} | 8 +- .../PythonNotebook7_original.ipynb} | 0 .../macos_terminal.png | Bin 27 files changed, 175 insertions(+), 418 deletions(-) delete mode 100644 book/exercise_notebooks/exercise_notebook_3_loops_debugging.zip rename book/exercise_notebooks/{exercise_notebook_3_loops_debugging.ipynb => exercise_notebook_4_debugging.ipynb} (79%) rename book/exercise_notebooks/{exercise_notebook_4_figures.ipynb => exercise_notebook_5_figures.ipynb} (95%) rename book/exercise_notebooks/{exercise_notebook_4_figures.zip => exercise_notebook_5_figures.zip} (100%) rename book/exercise_notebooks/{exercise_notebook_5_numpy.ipynb => exercise_notebook_6_numpy.ipynb} (97%) rename book/exercise_notebooks/{exercise_notebook_5_numpy.zip => exercise_notebook_6_numpy.zip} (100%) rename book/exercise_notebooks/{exercise_notebook_6_files.ipynb => exercise_notebook_7_files.ipynb} (100%) rename book/exercise_notebooks/{exercise_notebook_6_files.zip => exercise_notebook_7_files.zip} (100%) rename book/{notebook_3_structures_loops_debugging => notebook_3_structures_loops}/PythonNotebook3_data_structures.ipynb (100%) rename book/{notebook_3_structures_loops_debugging => notebook_3_structures_loops}/PythonNotebook3_first_page.ipynb (82%) rename book/{notebook_3_structures_loops_debugging => notebook_3_structures_loops}/PythonNotebook3_loops.ipynb (100%) rename book/{notebook_3_structures_loops_debugging => notebook_3_structures_loops}/PythonNotebook3_original.ipynb (100%) rename book/{notebook_3_structures_loops_debugging/PythonNotebook3_debugging.ipynb => notebook_4_debugging/PythonNotebook4_debugging.ipynb} (99%) create mode 100644 book/notebook_4_debugging/PythonNotebook4_first_page copy.ipynb rename book/{notebook_5_numpy/PythonNotebook5_first_page.ipynb => notebook_6_numpy/PythonNotebook6_first_page.ipynb} (99%) rename book/{notebook_5_numpy/PythonNotebook5_loading_data.ipynb => notebook_6_numpy/PythonNotebook6_loading_data.ipynb} (99%) rename book/{notebook_5_numpy/PythonNotebook5_original.ipynb => notebook_6_numpy/PythonNotebook6_original.ipynb} (100%) rename book/{notebook_5_numpy/PythonNotebook5_vectors_and_plotting_with_numpy.ipynb => notebook_6_numpy/PythonNotebook6_vectors_and_plotting_with_numpy.ipynb} (98%) rename book/{notebook_6_files/PythonNotebook6_first_page.ipynb => notebook_7_files/PythonNotebook7_first_page.ipynb} (97%) rename book/{notebook_5_numpy/PythonNotebook6_original.ipynb => notebook_7_files/PythonNotebook7_original.ipynb} (100%) rename book/{notebook_6_files => notebook_7_files}/macos_terminal.png (100%) diff --git a/book/_toc.yml b/book/_toc.yml index 44be873..0f6967c 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -34,28 +34,33 @@ parts: - file: notebook_2_smart_coding/PythonNotebook2_conditions.ipynb - file: exercise_notebooks/exercise_notebook_2_smart_coding.ipynb - - file: notebook_3_structures_loops_debugging/PythonNotebook3_first_page.ipynb + - file: notebook_3_structures_loops/PythonNotebook3_first_page.ipynb sections: - - file: notebook_3_structures_loops_debugging/PythonNotebook3_data_structures.ipynb - - file: notebook_3_structures_loops_debugging/PythonNotebook3_loops.ipynb - # - file: notebook_3_structures_loops_debugging/PythonNotebook3_debugging.ipynb + - file: notebook_3_structures_loops/PythonNotebook3_data_structures.ipynb + - file: notebook_3_structures_loops/PythonNotebook3_loops.ipynb + # - file: notebook_3_structures_loops/PythonNotebook3_debugging.ipynb - file: exercise_notebooks/exercise_notebook_3_structures_loops.ipynb # - file: exercise_notebooks/exercise_notebook_3_loops_debugging.ipynb - # - file: notebook_4_figures/PythonNotebook4_first_page.ipynb + # - file: notebook_4_debugging/PythonNotebook4_first_page.ipynb + # sections: + # - file: notebook_4_debugging/PythonNotebook4_debugging.ipynb + # - file: exercise_notebooks/exercise_notebook_4_debugging.ipynb + + # - file: notebook_5_figures/PythonNotebook5_first_page.ipynb # sections: - # - file: notebook_4_figures/PythonNotebook4_matplotlib.ipynb - # - file: exercise_notebooks/exercise_notebook_4_figures.ipynb + # - file: notebook_5_figures/PythonNotebook5_matplotlib.ipynb + # - file: exercise_notebooks/exercise_notebook_5_figures.ipynb - # - file: notebook_5_numpy/PythonNotebook5_first_page.ipynb + # - file: notebook_6_numpy/PythonNotebook6_first_page.ipynb # sections: - # - file: notebook_5_numpy/PythonNotebook5_vectors_and_plotting_with_numpy.ipynb - # - file: notebook_5_numpy/PythonNotebook5_loading_data.ipynb - # - file: exercise_notebooks/exercise_notebook_5_numpy.ipynb + # - file: notebook_6_numpy/PythonNotebook6_vectors_and_plotting_with_numpy.ipynb + # - file: notebook_6_numpy/PythonNotebook6_loading_data.ipynb + # - file: exercise_notebooks/exercise_notebook_6_numpy.ipynb - # - file: notebook_6_files/PythonNotebook6_first_page.ipynb + # - file: notebook_7_files/PythonNotebook7_first_page.ipynb # sections: - # - file: exercise_notebooks/exercise_notebook_6_files.ipynb + # - file: exercise_notebooks/exercise_notebook_7_files.ipynb # - caption: References diff --git a/book/exercise_notebooks/exercise_notebook_3_loops_debugging.zip b/book/exercise_notebooks/exercise_notebook_3_loops_debugging.zip deleted file mode 100644 index ce47be6725d756586b126ab9920a120dfadd6cea..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1891 zcmbW2dpy$%AIE=8E+uj)Dx}=WTz1@VdlbUlMzYZ{W5!X)C6mM4s}VxmQ5YJMXGAU~ zwj;M#NFrv3jCH1om}_pQ^ZfBV=kMq9{^RrgzP^8a|9rbUgM?%O(H~T$S@{D0h!&s> zU~rhIz|d%ne|SU;1|1O*<`40|77-B{?H`0e$6~Re;aG5JWPCU}7Iy>?5W-qaoDdqB zzmLA`brcYJNn(aXQkWs5kC-7GAAH1|vGkq|8U3^>uK(Qqxgbd^c~=5DVoG?zSN1xg zgYBnTcyZFwlR~64ddqDuB~p@nT#GkS+3y5flNE~~#U}^bO%#^;Kmp`Y(K_eeyg>UJ7#y0&%-CV%-}b_L`hMLYZtE> z8Z2IDmkqyM-ON!R9k{_^!$<{&7@m;{*=?&TpQ&H%QUG;7E71(IMtQ=G!YjupLE|?d zH)4k{v(hyr^STdFQX{W;c-F7c@%yci@2i9BA0uWb?r;WlD?I%8{g2&S-N^5GN7>TE zQQxn)r|S>F+(H_rcf?F-I^-$>tzBJQy&iRUVqMi@kE&)no~CaqCfzieN433auK)xGn}Rw_-(y>tiwLAzGeOk$o$ z>}}kHEGlWYRV)NRoir}EhVG+>6PP$@AhTa-WI#BoC zB}!-jxD#!P-(9E*l&8d1NAU$_xmL#b?r4&iK<^zRF)bT--}4)us)RXQTxX=d<9!Fq zL?`CED>TlM?A9=0mu@4sy@T2TWgCgs*JH^q=V(j54?_mTu_+dCABQ$5rSXu7KBRhK za&j^NwroiT)#j-=|tkkbTpDl|G3@Bc|r?@QF$y`}x?I)BS+!nVT{&ajI zX6?bmrw^7@QdBT|0TOyhMOXPWXCm{30n?}P)NRp>bY_lk7MJmHMz5mOhh_tUaG{kn z9yZ4!SctD^tl*@h8(qfiNiX_b|0$0hvRGy-K>o9&)~0Md^V;UR*T2PyR7Sbqwz%lSLnUZGiS^ac2EfyS*W;9!)yaV z{;Th**&6M??-FHrVz)WY@U_$&*>K6xx%~x}P5B^uM}Zt_)79j?!6hgUXY)r^!HB-zg}QXmAmkQ2;ey`J*=ZIfOIABAZoYqz zRNgD4XY%tNNG&plIF zft~i-LK0s?RJ3A4fW$2B;+=+A!jft7@fUalbUS@Yz3l9j5`98#)v~oIH(?(4)YZ6} zE*(k#Eg0EJN*i-JEr%Sda~eC}1tng>;}tV*jc8rFa4+&xMOt=r$|dQ#rNz8ECX1N| zI_K5&eFJSdM3IY<9eU{I(V`DGTise1O#bkS;-2iLe0gG&?fUC_d3+lHVM!Gcfr9kvnc#&FyUsO8a{W-;gL6!8Xwp?##s&j@|FiuC4XKo( diff --git a/book/exercise_notebooks/exercise_notebook_3_structures_loops.ipynb b/book/exercise_notebooks/exercise_notebook_3_structures_loops.ipynb index fe30ad6..ce4b076 100644 --- a/book/exercise_notebooks/exercise_notebook_3_structures_loops.ipynb +++ b/book/exercise_notebooks/exercise_notebook_3_structures_loops.ipynb @@ -18,7 +18,7 @@ "\n", "You can download this notebook and the additional files by clicking the download button({fa}`download`) in the top right and selecting \"Exercise notebook\". \n", "\n", - "```{custom_download_link} exercise_notebook_3_structures_loops_debugging.zip\n", + "```{custom_download_link} exercise_notebook_3_structures_loops.zip\n", ":text: \"Exercise notebook\"\n", ":replace_default: \"True\"\n", "```" diff --git a/book/exercise_notebooks/exercise_notebook_3_structures_loops_debugging.ipynb b/book/exercise_notebooks/exercise_notebook_3_structures_loops_debugging.ipynb index 4a1971d..5546204 100644 --- a/book/exercise_notebooks/exercise_notebook_3_structures_loops_debugging.ipynb +++ b/book/exercise_notebooks/exercise_notebook_3_structures_loops_debugging.ipynb @@ -14,338 +14,16 @@ " \n", "\n", "\n", - "# Exercise Notebook 3 - Data structures, loops and debugging\n", + "# Exercise Notebook 3 - Part 2 - Loops and debugging\n", "\n", "You can download this notebook and the additional files by clicking the download button({fa}`download`) in the top right and selecting \"Exercise notebook\". \n", "\n", - "```{custom_download_link} exercise_notebook_3_structures_loops_debugging.zip\n", + "```{custom_download_link} exercise_notebook_3_structures_loops.zip\n", ":text: \"Exercise notebook\"\n", ":replace_default: \"True\"\n", "```" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
Exercise 3.1.1

\n", - "\n", - "Now, let's get down to practice.

Your first task is to finish the pack_variables() function — a function which will combine all inputs in one list and return it.\n", - "\n", - "More precisely, this function will receive $5$ arguments as input and you have to return a list with these $5$ elements inside.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def pack_variables(arg1, arg2, arg3, arg4, arg5):\n", - " ...\n", - "\n", - "\n", - "print(pack_variables(1, 2, 4, 22, 7))\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
Exercise 3.1.2

\n", - "\n", - "Here, you will have to perform a quality assessment on a received list of GNSS measurements. But a simple one.\n", - "\n", - "You have to check whether the received data has more than $1000$ measurements, in that case we know the receiver was running for a long time without being interrupted.\n", - "If it is shorter than $1000$, we assume there were some interruptions. Hence, your function should return a message whether the data is fine or not.\n", - "\n", - "You may want to add print(measurements) to the cell to check what goes on inside the function.
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def check_data(measurements):\n", - " ...\n", - "\n", - "#You can check your code below, where we simulate 1250 measurements\n", - "import random \n", - "gnss_data = [random.random() * 2.2e8 for i in range(1250)]\n", - "\n", - "print(check_data(gnss_data))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "explanations for the test data will follow later, but in brief:\n", - " * `random.random()` returns a random number between 0 and 1\n", - " * `[... for i in range(...)]` is a _list comprehension_, creating a list from an expression.\n", - " * here a list of 1250 random numbers is created\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
Exercise 3.1.3

\n", - "\n", - "In this exercise you will practice how to access data from a dictionary. Sometimes it is easier to work with the most convenient data type, that is best suited for a specific task. In this example, you have to write a function which accepts data stored in a dictionary and saves some data from it. More precisely, you have to select the $x$ and $y$ coordinates saved in the input_dict dictionary, and return them as a tuple, with $x$ being the first entry.
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# you do not have to change anything in this cell, just run it\n", - "\n", - "input_dict = {\n", - " 'ID': '334856',\n", - " 'operator_name': 'Jarno',\n", - " 'observation_amount': '2485',\n", - " 'loc_x': [2, 5, 10, 12, -5, 8, 27, 1],\n", - " 'loc_y': [6, 1, -5, 15, 4, 8, 0, 10]\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def unpack_dictionary(input_dict):\n", - " ...\n", - "\n", - "\n", - "print(unpack_dictionary(input_dict))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "su7ODKnqB7tv", - "nbgrader": { - "grade": false, - "locked": true, - "solution": false - } - }, - "source": [ - "
Exercise 3.2.1\n", - "\n", - "
\n", - "\n", - "In this exercise you will write your own Celsius to Fahrenheit converter! Your task is to write a function, which will accept the list of temperatures temp_c, in Celsius, and will output a list with the same temperatures, but in Fahrenheit. \n", - "\n", - "Hint: create an empty list for the result, then append values to this list. See the \"personalized greeting\" example in Section 3.2.\n", - "\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "ldeM_71XgK--", - "nbgrader": { - "grade": false, - "locked": true, - "solution": false - } - }, - "outputs": [], - "source": [ - "# you do not need to change anything in this cell\n", - "\n", - "temperatures_c = [-1, -1.2, 1.3, 6.4, 11.2, 14.8, 17.8, 17.7, 13.7, 8.5, 4.1, 0.9]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "WYqtQ21Kgqzs" - }, - "outputs": [], - "source": [ - "def celsius_to_fahrenheit(temp_c):\n", - " ...\n", - "\n", - "print(celsius_to_fahrenheit(temperatures_c))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "2iKtqd2XhAcU", - "nbgrader": { - "grade": false, - "locked": true, - "solution": false - } - }, - "source": [ - "
Exercise 3.2.2

Your task here is to write a function which will analyze a broadcasting message of the following format: \"satellite_ids;date\", where the first part of the message contains unique lowercase letters, each corresponding to a different satellite ID, and the last part contains the date of the message.

\n", - "Here are some examples:\n", - " \"agf;06062022\" (3 satellites: a, g, and f),\n", - " \"abcdefgops;03121999\" (10 satellites), \n", - " \"xyz;11112011\" (3 satellites).\n", - "

Your task is to write a function, which for a provided broadcast message, will count the number of satellites mentioned in the message.\n", - "
\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "id": "niMqThVgiVeG" - }, - "outputs": [], - "source": [ - "def count_satellites(message):\n", - " ...\n", - "\n", - "# Check that with the example below you count 5 satellites\n", - "print(count_satellites(\"hpzde;12122007\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "GFziFh2Misx_", - "nbgrader": { - "grade": false, - "locked": true, - "solution": false - } - }, - "source": [ - "
Exercise 3.2.3\n", - "
\n", - "\n", - "Here you need to write a function that is able to sort any list consisting only of real numbers, in the descending order. For example, the list $[19, 5, 144, 6]$ becomes $[144, 19, 6, 5]$.\n", - "\n", - "\n", - "Hint: use a built-in sorted() function to sort the list in ascending order, and then think of a clever way to change the order this list to descending order.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "2DB2jWVpi9Lr", - "outputId": "c6af4f43-7138-4d09-b1ae-a913154dd107" - }, - "outputs": [], - "source": [ - "def sort_list(unsorted_list):\n", - " ...\n", - "\n", - "print(sort_list([9, 3, -1, 5, 1, -9, 1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "nbgrader": { - "grade": false, - "locked": true, - "solution": false - } - }, - "source": [ - "
Exercise 3.2.4

\n", - "Use a for loop and what you learned about range() to print out every third element of the list L, starting from the second.\n", - "
\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "L = ['a', '1', 'b', 'c', '2', 'd', 'e', '3', 'f', 'g', '4', 'h'] # you don't need to change L\n", - "\n", - "# your loop here\n", - "..." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "nbgrader": { - "grade": false, - "locked": true, - "solution": false - } - }, - "source": [ - "
\n", - "Exercise 3.2.5

Write a function that converts a number from degrees to radians.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def DegToRad(deg):\n", - " ...\n", - "\n", - "Angle = 180 # Degrees\n", - "print(f\"An angle of {Angle} Degrees is equal to {DegToRad(Angle):.3f} radians\")" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "nbgrader": { - "grade": false, - "locked": true, - "solution": false - } - }, - "source": [ - "
\n", - "Exercise 3.2.6

Write a function that takes four inputs:\n", - "\n", - "$(x_1, y_1, x_2, y_2)$ and computes the Euclidian distance between point 1 $(x_1,y_1)$ and point 2 $(x_2,y_2)$.\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import math # \n", - "\n", - "# def distance ...\n", - "# ...\n", - "# ...\n", - "\n", - "x1, y1 = 1, 1\n", - "x2, y2 = 2, 3\n", - "\n", - "print(f\"Distance between points ({x1}, {y1}) and ({x2}, {y2}) is {distance(x1, y1, x2, y2):.3f}\")" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -364,7 +42,9 @@ "outputs": [], "source": [ "def is_prime(n):\n", - " return True # or False" + " ...\n", + " return True # or False\n", + "\n" ] }, { @@ -389,6 +69,10 @@ "prime_list = ...\n", "prime_sum = ...\n", "\n", + "\n", + "print(prime_list)\n", + "print(prime_sum)\n", + "\n", "print(prime_list)\n", "print(prime_sum)" ] @@ -410,10 +94,18 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "EC&T\n" + ] + } + ], "source": [ "def get_abbreviation():\n", - " my abbreviation = \"AES\"\n", + " my abbreviation = \"EC&T\"\n", " return my_abbreviation\n", " \n", "print(get_abbreviation())" @@ -447,20 +139,14 @@ " else: \n", " return x ** factorial(x-1)\n", "\n", + "\n", "factorial(4)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -474,7 +160,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.0" + "version": "3.13.2" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -493,11 +179,6 @@ "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false - }, - "vscode": { - "interpreter": { - "hash": "1fe2f2b718b1108b9c4176932db8a0ead471245140baaa21ea96a4066683e6b2" - } } }, "nbformat": 4, diff --git a/book/exercise_notebooks/exercise_notebook_3_structures_loops_debugging.zip b/book/exercise_notebooks/exercise_notebook_3_structures_loops_debugging.zip index 7c878e402cd7810f76fb9877ee50e07f0524f922..ce47be6725d756586b126ab9920a120dfadd6cea 100644 GIT binary patch delta 1804 zcmV+n2lM#7BI6D*P)h>@6aWYS2mq#oJzD?(0000000000001cfAOK}}WpZO_b7fy{ zZ**m1Z*OZ~Gm$(hf4P_1XmF(3Xw#e8XysUcZ{s!+{Xd^#s-}0zB9Y@{4?P%8iehiu z2H0B^ZHm3(Tqu-8**sIEmZY*)7y0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Gy!is=~ zp<)-@+}-G|Vq*rrr&SMnTFGU(nZwX*u|#gA5&T=#-kS{kXR7gC&%~bb>QqRxjEaIs zR=w&2-ugo7?Qr`R53*^8_34)wt6J1HYXY|poTfniq|R=Za~H8)rG zZ#2ml6BASgDc*T%u{x?6G^}>O`wj=gwk&{?fQbuT3*sex%YHIN0gx>Nyim-{>erat zp=BYXRO)4Xw#5?dzF-(mwh~acCVtsy&rv;Fc7uOz{_v_)E5xO2u#$1LGpHS#D#xngxiGx~g8X z3mvuevtxdl0c%u$w47&WO7#>O_Y&qOez@oDhn_dw4-cZTx3_yR^5bxy4jGNdd!9eu z@y5fDQtEq*9_-TbaCdiif5dh}-%i=uE{+cBXm4Hs@p1b*fSg+*1LFtR5B?8OO9u!z zX#jRB5C8zcIsgDrO928D0~7!V00;nNSv^}gX#jRB5C8xLz&Zc`G?V)VB?@zNa&=>L ob#i5MkufJ71pompP1\n", "\n", "\n", - "# Exercise Notebook 3 - Part 2 - Loops and debugging\n", + "# Exercise Notebook 4 - Debugging\n", "\n", "You can download this notebook and the additional files by clicking the download button({fa}`download`) in the top right and selecting \"Exercise notebook\". \n", "\n", - "```{custom_download_link} exercise_notebook_3_structures_loops_debugging.zip\n", + "```{custom_download_link} exercise_notebook_4_debugging.zip\n", ":text: \"Exercise notebook\"\n", ":replace_default: \"True\"\n", "```" @@ -29,7 +29,7 @@ "metadata": {}, "source": [ "
\n", - "Exercise 3.2.7

Write a function that determines if its argument is a prime number.\n", + "Exercise 4.1

Write a function that determines if its argument is a prime number.\n", "\n", "* Hint 1: an integer $n$ is prime if $n > 1$ and $n$ is not divisible by any smaller integer $> 1$\n", "* Hint 2: divisibility can be tested with the % operator. If n % i is $0$, n is divisible by i.
" @@ -42,9 +42,7 @@ "outputs": [], "source": [ "def is_prime(n):\n", - " ...\n", - " return True # or False\n", - "\n" + " return True # or False" ] }, { @@ -52,7 +50,7 @@ "metadata": {}, "source": [ "
\n", - "Exercise 3.2.8

\n", + "Exercise 4.2

\n", "\n", "Use your is_prime() function to create a list of all primes $< 1000$. What is the sum of all primes $< 1000$?\n", "\n", @@ -69,10 +67,6 @@ "prime_list = ...\n", "prime_sum = ...\n", "\n", - "\n", - "print(prime_list)\n", - "print(prime_sum)\n", - "\n", "print(prime_list)\n", "print(prime_sum)" ] @@ -87,25 +81,17 @@ } }, "source": [ - "
(Fixing) Exercise 3.3.1

Fix the syntax errors so it prints \"AES\" without removing the variable that holds it. You'll need to fix 2 errors.
" + "
(Fixing) Exercise 4.3

Fix the syntax errors so it prints \"AES\" without removing the variable that holds it. You'll need to fix 2 errors.
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "EC&T\n" - ] - } - ], + "outputs": [], "source": [ "def get_abbreviation():\n", - " my abbreviation = \"EC&T\"\n", + " my abbreviation = \"AES\"\n", " return my_abbreviation\n", " \n", "print(get_abbreviation())" @@ -121,7 +107,7 @@ } }, "source": [ - "
(Fixing) Exercise 3.3.2

Find the semantic error in this function.\n", + "
(Fixing) Exercise 4.4

Find the semantic error in this function.\n", "\n", "Hint: The factorial n! is defined as n! = n * (n - 1) * (n - 2) * ... * 2 * 1. The function uses the fact that if n > 0, n! = n * (n - 1)!. This is an example of a _recursive_ function, a function that calls itself.
" ] @@ -139,14 +125,20 @@ " else: \n", " return x ** factorial(x-1)\n", "\n", - "\n", "factorial(4)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "base", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -160,7 +152,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.2" + "version": "3.10.0" }, "latex_envs": { "LaTeX_envs_menu_present": true, @@ -179,6 +171,11 @@ "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false + }, + "vscode": { + "interpreter": { + "hash": "1fe2f2b718b1108b9c4176932db8a0ead471245140baaa21ea96a4066683e6b2" + } } }, "nbformat": 4, diff --git a/book/exercise_notebooks/exercise_notebook_4_figures.ipynb b/book/exercise_notebooks/exercise_notebook_5_figures.ipynb similarity index 95% rename from book/exercise_notebooks/exercise_notebook_4_figures.ipynb rename to book/exercise_notebooks/exercise_notebook_5_figures.ipynb index 0dfa652..9652116 100644 --- a/book/exercise_notebooks/exercise_notebook_4_figures.ipynb +++ b/book/exercise_notebooks/exercise_notebook_5_figures.ipynb @@ -15,7 +15,7 @@ " \n", "\n", "\n", - "# Exercise Notebook 4 - Figures\n", + "# Exercise Notebook 5 - Figures\n", "\n", "```{admonition} Note\n", ":class: important\n", @@ -24,13 +24,13 @@ "+++\n", "```\n", "\n", - "```{custom_download_link} ../exercise_notebooks/exercise_notebook_4_figures.zip\n", + "```{custom_download_link} ../exercise_notebooks/exercise_notebook_5_figures.zip\n", ":text: \"Exercise notebook\"\n", ":replace_default: \"True\"\n", "```\n", "\n", "\n", - "# 4.1 Plotting with Matplotlib\n", + "# 5.1 Plotting with Matplotlib\n", "\n", "In this notebook we will learn how to make figures in Python, using the `matplotlib.pyplot` module. We start by importing the module." ] @@ -101,7 +101,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.1

\n", + "
Exercise 5.1.1

\n", "\n", "What if your data does not represent a curve, but are just points in x-y space? For example in a scatter-plot. Plot the data from above, using the function `plt.scatter()`.
" ] @@ -117,7 +117,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 4.1.2 Multiple curves, legends" + "## 5.1.2 Multiple curves, legends" ] }, { @@ -145,7 +145,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.2

\n", + "
Exercise 5.1.2

\n", " \n", "* Create plots of the three temperature time series. Just do three plt.plot() calls after each other. Like this: `plt.plot(month, T_NL)`\n", "\n", @@ -195,7 +195,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.3 - Plotting in style

\n", + "
Exercise 5.1.3 - Plotting in style

\n", " \n", "In the Matplotlib documentation (see above), find out how you can set the _line style_ (solid line, dashed line, dotted line, ...) and _line color_ in a plot. Copy the temperature plot above, and choose line styles and line colors for the curves.\n", "
\n", @@ -213,7 +213,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 4.1.3 Plotting in 3D\n" + "## 5.1.3 Plotting in 3D\n" ] }, { @@ -254,7 +254,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.4

\n", + "
Exercise 5.1.4

\n", "\n", "Copy the parametric curve example above, modify it to draw something else. Color the curve in your favourite color. Add labels to the x, y, and z axes.\n", "\n", @@ -269,7 +269,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.5 - Bar graph

\n", + "
Exercise 5.1.5 - Bar graph

\n", "\n", "In the Matplotlib documentation, find out how to make bar graphs. Plot the monthly mean rainfall data below in a bar graph. Add labels on the axes.\n", "\n", diff --git a/book/exercise_notebooks/exercise_notebook_4_figures.zip b/book/exercise_notebooks/exercise_notebook_5_figures.zip similarity index 100% rename from book/exercise_notebooks/exercise_notebook_4_figures.zip rename to book/exercise_notebooks/exercise_notebook_5_figures.zip diff --git a/book/exercise_notebooks/exercise_notebook_5_numpy.ipynb b/book/exercise_notebooks/exercise_notebook_6_numpy.ipynb similarity index 97% rename from book/exercise_notebooks/exercise_notebook_5_numpy.ipynb rename to book/exercise_notebooks/exercise_notebook_6_numpy.ipynb index 3d5bc60..12d7512 100644 --- a/book/exercise_notebooks/exercise_notebook_5_numpy.ipynb +++ b/book/exercise_notebooks/exercise_notebook_6_numpy.ipynb @@ -14,14 +14,12 @@ " \n", "\n", "\n", - "# Exercise Notebook 5: Numpy\n", + "# Exercise Notebook 6: Numpy\n", "
\n", "\n", "You can download this notebook and the additional files by clicking the download button({fa}`download`) in the top right and selecting \"Exercise notebook\". \n", "\n", - "Submit it as \"Notebook6_Group_.ipynb\".\n", - "\n", - "```{custom_download_link} exercise_notebook_5_numpy.zip\n", + "```{custom_download_link} exercise_notebook_6_numpy.zip\n", ":text: \"Exercise notebook\"\n", ":replace_default: \"True\"\n", "```" diff --git a/book/exercise_notebooks/exercise_notebook_5_numpy.zip b/book/exercise_notebooks/exercise_notebook_6_numpy.zip similarity index 100% rename from book/exercise_notebooks/exercise_notebook_5_numpy.zip rename to book/exercise_notebooks/exercise_notebook_6_numpy.zip diff --git a/book/exercise_notebooks/exercise_notebook_6_files.ipynb b/book/exercise_notebooks/exercise_notebook_7_files.ipynb similarity index 100% rename from book/exercise_notebooks/exercise_notebook_6_files.ipynb rename to book/exercise_notebooks/exercise_notebook_7_files.ipynb diff --git a/book/exercise_notebooks/exercise_notebook_6_files.zip b/book/exercise_notebooks/exercise_notebook_7_files.zip similarity index 100% rename from book/exercise_notebooks/exercise_notebook_6_files.zip rename to book/exercise_notebooks/exercise_notebook_7_files.zip diff --git a/book/notebook_3_structures_loops_debugging/PythonNotebook3_data_structures.ipynb b/book/notebook_3_structures_loops/PythonNotebook3_data_structures.ipynb similarity index 100% rename from book/notebook_3_structures_loops_debugging/PythonNotebook3_data_structures.ipynb rename to book/notebook_3_structures_loops/PythonNotebook3_data_structures.ipynb diff --git a/book/notebook_3_structures_loops_debugging/PythonNotebook3_first_page.ipynb b/book/notebook_3_structures_loops/PythonNotebook3_first_page.ipynb similarity index 82% rename from book/notebook_3_structures_loops_debugging/PythonNotebook3_first_page.ipynb rename to book/notebook_3_structures_loops/PythonNotebook3_first_page.ipynb index 582da00..77161dd 100644 --- a/book/notebook_3_structures_loops_debugging/PythonNotebook3_first_page.ipynb +++ b/book/notebook_3_structures_loops/PythonNotebook3_first_page.ipynb @@ -14,10 +14,10 @@ " \n", "\n", "\n", - "# 3: Data structures, loops and debugging\n", + "# 3: Data structures and loops\n", "
\n", "\n", - "In this chapter, we advance our Python programming skills by diving into key concepts that form the backbone of effective coding. First, we explore data structures, including lists, tuples, and dictionaries, along with techniques for slicing and manipulating them efficiently. Next, we examine loops, focusing on for loops, while loops, and powerful tools like the `range()` function and the `continue` keyword for controlling flow. Finally, we introduce debugging, covering the three main types of errors—syntax, runtime, and logical—and strategies for identifying and resolving issues in your code. Mastering these topics will further refine your programming precision and problem-solving expertise, laying a strong foundation for tackling complex Python projects. \n", + "In this chapter, we advance our Python programming skills by diving into key concepts that form the backbone of effective coding. First, we explore data structures, including lists, tuples, and dictionaries, along with techniques for slicing and manipulating them efficiently. Next, we examine loops, focusing on for loops, while loops, and powerful tools like the `range()` function and the `continue` keyword for controlling flow. Mastering these topics will further refine your programming precision. \n", "\n", "```{admonition} Attention\n", ":class: danger\n", diff --git a/book/notebook_3_structures_loops_debugging/PythonNotebook3_loops.ipynb b/book/notebook_3_structures_loops/PythonNotebook3_loops.ipynb similarity index 100% rename from book/notebook_3_structures_loops_debugging/PythonNotebook3_loops.ipynb rename to book/notebook_3_structures_loops/PythonNotebook3_loops.ipynb diff --git a/book/notebook_3_structures_loops_debugging/PythonNotebook3_original.ipynb b/book/notebook_3_structures_loops/PythonNotebook3_original.ipynb similarity index 100% rename from book/notebook_3_structures_loops_debugging/PythonNotebook3_original.ipynb rename to book/notebook_3_structures_loops/PythonNotebook3_original.ipynb diff --git a/book/notebook_3_structures_loops_debugging/PythonNotebook3_debugging.ipynb b/book/notebook_4_debugging/PythonNotebook4_debugging.ipynb similarity index 99% rename from book/notebook_3_structures_loops_debugging/PythonNotebook3_debugging.ipynb rename to book/notebook_4_debugging/PythonNotebook4_debugging.ipynb index af03db4..b805833 100644 --- a/book/notebook_3_structures_loops_debugging/PythonNotebook3_debugging.ipynb +++ b/book/notebook_4_debugging/PythonNotebook4_debugging.ipynb @@ -14,7 +14,7 @@ " \n", "\n", "\n", - "# 3.3 Debugging" + "# 4.1 Debugging" ] }, { diff --git a/book/notebook_4_debugging/PythonNotebook4_first_page copy.ipynb b/book/notebook_4_debugging/PythonNotebook4_first_page copy.ipynb new file mode 100644 index 0000000..9a24edb --- /dev/null +++ b/book/notebook_4_debugging/PythonNotebook4_first_page copy.ipynb @@ -0,0 +1,76 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "nbgrader": { + "grade": false, + "locked": true, + "solution": false + } + }, + "source": [ + "
\n", + " \n", + "
\n", + "\n", + "# 4: Debugging\n", + "
\n", + "\n", + "In this chapter, we introduce debugging. We cover the three main types of errors—syntax, runtime, and logical—and strategies for identifying and resolving issues in your code. Mastering these topics will refine your problem-solving expertise, laying a strong foundation for tackling complex Python projects. \n", + "\n", + "```{admonition} Attention\n", + ":class: danger\n", + "\n", + "\n", + "Your problem-solving expertise will only develop if you tackle these problems head-on. Asking ChatGPT or another AI to solve these basic problems will not add anything to you (or them).\n", + "+++\n", + "```" + ] + } + ], + "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.10.0" + }, + "latex_envs": { + "LaTeX_envs_menu_present": true, + "autoclose": false, + "autocomplete": true, + "bibliofile": "biblio.bib", + "cite_by": "apalike", + "current_citInitial": 1, + "eqLabelWithNumbers": true, + "eqNumInitial": 1, + "hotkeys": { + "equation": "Ctrl-E", + "itemize": "Ctrl-I" + }, + "labels_anchors": false, + "latex_user_defs": false, + "report_style_numbering": false, + "user_envs_cfg": false + }, + "vscode": { + "interpreter": { + "hash": "1fe2f2b718b1108b9c4176932db8a0ead471245140baaa21ea96a4066683e6b2" + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/book/notebook_5_figures/PythonNotebook5_first_page.ipynb b/book/notebook_5_figures/PythonNotebook5_first_page.ipynb index 68ce216..3e1b06c 100644 --- a/book/notebook_5_figures/PythonNotebook5_first_page.ipynb +++ b/book/notebook_5_figures/PythonNotebook5_first_page.ipynb @@ -8,7 +8,7 @@ " \n", "\n", "\n", - "# 4: Figures\n", + "# 5: Figures\n", "
\n", "\n", "In this chapter, we focus on enhancing our data visualization skills by exploring the `matplotlib` library. We begin with the basics of creating 2D plots and customizing their appearance. Next, we expand our visualization toolkit to include 3D plotting. Finally, we explore bar graphs for categorical data representation. \n", diff --git a/book/notebook_5_figures/PythonNotebook5_matplotlib.ipynb b/book/notebook_5_figures/PythonNotebook5_matplotlib.ipynb index d5e5488..7ba7ec5 100644 --- a/book/notebook_5_figures/PythonNotebook5_matplotlib.ipynb +++ b/book/notebook_5_figures/PythonNotebook5_matplotlib.ipynb @@ -22,13 +22,13 @@ "+++\n", "```\n", "\n", - "```{custom_download_link} ../exercise_notebooks/exercise_notebook_week_5.zip\n", + "```{custom_download_link} ../exercise_notebooks/exercise_notebook_5_figures.zip\n", ":text: \"Exercise notebook\"\n", ":replace_default: \"True\"\n", "```\n", "\n", "\n", - "# 4.1 Plotting with Matplotlib\n", + "# 5.1 Plotting with Matplotlib\n", "\n", "In this notebook we will learn how to make figures in Python, using the `matplotlib.pyplot` module. We start by importing the module." ] @@ -99,7 +99,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.1

\n", + "
Exercise 5.1.1

\n", "\n", "What if your data does not represent a curve, but are just points in x-y space? For example in a scatter-plot. Plot the data from above, using the function `plt.scatter()`.
" ] @@ -115,7 +115,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 4.1.2 Multiple curves, legends" + "## 5.1.2 Multiple curves, legends" ] }, { @@ -143,7 +143,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.2

\n", + "
Exercise 5.1.2

\n", " \n", "* Create plots of the three temperature time series. Just do three plt.plot() calls after each other. Like this: `plt.plot(month, T_NL)`\n", "\n", @@ -193,7 +193,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.3 - Plotting in style

\n", + "
Exercise 5.1.3 - Plotting in style

\n", " \n", "In the Matplotlib documentation (see above), find out how you can set the _line style_ (solid line, dashed line, dotted line, ...) and _line color_ in a plot. Copy the temperature plot above, and choose line styles and line colors for the curves.\n", "
\n", @@ -211,7 +211,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 4.1.3 Plotting in 3D\n" + "## 5.1.3 Plotting in 3D\n" ] }, { @@ -252,7 +252,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.4

\n", + "
Exercise 5.1.4

\n", "\n", "Copy the parametric curve example above, modify it to draw something else. Color the curve in your favourite color. Add labels to the x, y, and z axes.\n", "\n", @@ -276,7 +276,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "
Exercise 4.1.5 - Bar graph

\n", + "
Exercise 5.1.5 - Bar graph

\n", "\n", "In the Matplotlib documentation, find out how to make bar graphs. Plot the monthly mean rainfall data below in a bar graph. Add labels on the axes.\n", "\n", diff --git a/book/notebook_5_numpy/PythonNotebook5_first_page.ipynb b/book/notebook_6_numpy/PythonNotebook6_first_page.ipynb similarity index 99% rename from book/notebook_5_numpy/PythonNotebook5_first_page.ipynb rename to book/notebook_6_numpy/PythonNotebook6_first_page.ipynb index a56ace4..92059b6 100644 --- a/book/notebook_5_numpy/PythonNotebook5_first_page.ipynb +++ b/book/notebook_6_numpy/PythonNotebook6_first_page.ipynb @@ -14,7 +14,7 @@ " \n", "\n", "\n", - "# 5: Numpy\n", + "# 6: Numpy\n", "
\n", "\n", "In this chapter, we delve into essential numerical computing techniques using the `numpy` library. We begin by exploring the foundational concepts of vectors and matrices, followed by performing mathematical operations with arrays. Next, we demonstrate how to visualize data using `numpy` arrays for plotting. We then cover methods for loading data from files into `numpy` arrays. Finally, we introduce surface and color plots to enhance your data representation skills. \n", diff --git a/book/notebook_5_numpy/PythonNotebook5_loading_data.ipynb b/book/notebook_6_numpy/PythonNotebook6_loading_data.ipynb similarity index 99% rename from book/notebook_5_numpy/PythonNotebook5_loading_data.ipynb rename to book/notebook_6_numpy/PythonNotebook6_loading_data.ipynb index f02c49f..87f8e62 100644 --- a/book/notebook_5_numpy/PythonNotebook5_loading_data.ipynb +++ b/book/notebook_6_numpy/PythonNotebook6_loading_data.ipynb @@ -14,7 +14,7 @@ " \n", "\n", "\n", - "# 5.2 Loading data from a file" + "# 6.2 Loading data from a file" ] }, { @@ -133,7 +133,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 5.2.1 Surface and color plots\n", + "## 6.2.1 Surface and color plots\n", "\n", "Next you will learn some more plotting with matplotlib, namely to plot a function of two variables, f(x,y). Either as a 2D image with colors showing the value, or as a surface in 3D where z = f(x,y). \n", "\n", diff --git a/book/notebook_5_numpy/PythonNotebook5_original.ipynb b/book/notebook_6_numpy/PythonNotebook6_original.ipynb similarity index 100% rename from book/notebook_5_numpy/PythonNotebook5_original.ipynb rename to book/notebook_6_numpy/PythonNotebook6_original.ipynb diff --git a/book/notebook_5_numpy/PythonNotebook5_vectors_and_plotting_with_numpy.ipynb b/book/notebook_6_numpy/PythonNotebook6_vectors_and_plotting_with_numpy.ipynb similarity index 98% rename from book/notebook_5_numpy/PythonNotebook5_vectors_and_plotting_with_numpy.ipynb rename to book/notebook_6_numpy/PythonNotebook6_vectors_and_plotting_with_numpy.ipynb index 0b960ad..5364a66 100644 --- a/book/notebook_5_numpy/PythonNotebook5_vectors_and_plotting_with_numpy.ipynb +++ b/book/notebook_6_numpy/PythonNotebook6_vectors_and_plotting_with_numpy.ipynb @@ -14,7 +14,7 @@ " \n", "\n", "\n", - "# 5.1 Introduction to numpy" + "# 6.1 Introduction to numpy" ] }, { @@ -104,7 +104,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 5.1.1 Array math and plotting\n", + "# 6.1.1 Array math and plotting\n", "\n", "Now we can do math with the arrays:" ] @@ -269,7 +269,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 5.1.2 Saving your plots\n", + "## 6.1.2 Saving your plots\n", "\n", "One more important matplotlib function is saving plots in a file, so that you can use them in reports.\n" ] diff --git a/book/notebook_6_files/PythonNotebook6_first_page.ipynb b/book/notebook_7_files/PythonNotebook7_first_page.ipynb similarity index 97% rename from book/notebook_6_files/PythonNotebook6_first_page.ipynb rename to book/notebook_7_files/PythonNotebook7_first_page.ipynb index 3484912..4f0b17a 100644 --- a/book/notebook_6_files/PythonNotebook6_first_page.ipynb +++ b/book/notebook_7_files/PythonNotebook7_first_page.ipynb @@ -14,9 +14,9 @@ " \n", "\n", "\n", - "# 6: Python files\n", + "# 7: Python files\n", "\n", - "## 6.1 Creating a .py File\n", + "## 7.1 Creating a .py File\n", "\n", "To create a Python (`.py`) file, follow these instructions:\n", "\n", @@ -35,7 +35,7 @@ "\n", "\n", "\n", - "## 6.2 Opening the terminal\n", + "## 7.2 Opening the terminal\n", "\n", "`````{tab-set}\n", "````{tab-item} Windows\n", @@ -53,7 +53,7 @@ "````\n", "`````\n", "\n", - "## 6.3 Running a Python file\n", + "## 7.3 Running a Python file\n", "\n", "In your Anaconda Prompt (Windows) or terminal (MacOS), first navigate to the location of your Python file using the terminal commands demonstrated in class. For a summary of these commands you can refer to [this page](https://mude.citg.tudelft.nl/2024/book/external/learn-programming/book/install/common/cli.html#basic-cli-skills-cheat-sheets).\n", "\n", diff --git a/book/notebook_5_numpy/PythonNotebook6_original.ipynb b/book/notebook_7_files/PythonNotebook7_original.ipynb similarity index 100% rename from book/notebook_5_numpy/PythonNotebook6_original.ipynb rename to book/notebook_7_files/PythonNotebook7_original.ipynb diff --git a/book/notebook_6_files/macos_terminal.png b/book/notebook_7_files/macos_terminal.png similarity index 100% rename from book/notebook_6_files/macos_terminal.png rename to book/notebook_7_files/macos_terminal.png