diff --git a/_sources/chap01.ipynb b/_sources/chap01.ipynb index c54b714..59da823 100644 --- a/_sources/chap01.ipynb +++ b/_sources/chap01.ipynb @@ -69,7 +69,6 @@ ] }, "source": [ - "(chapter_programming)=\n", "(chapter_programming)=\n", "# Programming as a way of thinking\n", "\n", @@ -1442,7 +1441,11 @@ "cell_type": "code", "execution_count": null, "id": "06d3e72c", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -1783,7 +1786,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap02.ipynb b/_sources/chap02.ipynb index fda295c..52fde07 100644 --- a/_sources/chap02.ipynb +++ b/_sources/chap02.ipynb @@ -1365,7 +1365,11 @@ "cell_type": "code", "execution_count": null, "id": "c9e6cab4", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -1579,7 +1583,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" }, "vscode": { "interpreter": { diff --git a/_sources/chap03.ipynb b/_sources/chap03.ipynb index a5e025f..401b7ce 100644 --- a/_sources/chap03.ipynb +++ b/_sources/chap03.ipynb @@ -811,7 +811,7 @@ "id": "1fe8ee82", "metadata": { "tags": [ - "remove-cell" + "remove-print" ] }, "outputs": [ @@ -824,9 +824,10 @@ } ], "source": [ - "# This cell tells Jupyter to display error messages with tracebacks\n", + "# This cell tells Jupyter to provide detailed debugging information\n", + "# when a runtime error occurs, including a traceback.\n", "\n", - "%xmode Plain" + "%xmode Verbose" ] }, { @@ -971,7 +972,11 @@ "cell_type": "code", "execution_count": null, "id": "3f77b428", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -1078,16 +1083,7 @@ "id": "7aa95014", "metadata": {}, "outputs": [], - "source": [ - "def triangle(string, height):\n", - " \"\"\"Make a triangle shape by printing a string repeatedly.\n", - " \n", - " string: characters to be repeated\n", - " height: number of lines in the triangle\n", - " \"\"\"\n", - " for i in range(height+1):\n", - " print(string * i)" - ] + "source": [] }, { "cell_type": "code", @@ -1130,17 +1126,7 @@ "id": "bcedab79", "metadata": {}, "outputs": [], - "source": [ - "def rectangle(string, width, height):\n", - " \"\"\"Make a rectangle by printing a string repeatedly.\n", - " \n", - " string: characters to be repeated\n", - " width: number of repetitions on each line\n", - " height: number of lines\n", - " \"\"\"\n", - " for i in range(height+1):\n", - " print(string * width)" - ] + "source": [] }, { "cell_type": "code", @@ -1785,7 +1771,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap04.ipynb b/_sources/chap04.ipynb index ce46728..75be762 100644 --- a/_sources/chap04.ipynb +++ b/_sources/chap04.ipynb @@ -64,7 +64,6 @@ ] }, "source": [ - "(section_turtle_module)=\n", "(section_turtle_module)=\n", "## The jupyturtle module\n", "\n", @@ -390,7 +389,6 @@ ] }, "source": [ - "(section_encapsulation)=\n", "(section_encapsulation)=\n", "## Encapsulation and generalization\n", "\n", @@ -1320,7 +1318,6 @@ ] }, "source": [ - "(section_docstring)=\n", "(section_docstring)=\n", "## Docstrings\n", "\n", @@ -1440,7 +1437,11 @@ "cell_type": "code", "execution_count": 47, "id": "9f94061e", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [ { "name": "stdout", @@ -7903,7 +7904,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap05.ipynb b/_sources/chap05.ipynb index 1cfc355..dfc4a2c 100644 --- a/_sources/chap05.ipynb +++ b/_sources/chap05.ipynb @@ -1668,7 +1668,11 @@ "cell_type": "code", "execution_count": null, "id": "66aae3cb", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -3393,7 +3397,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap06.ipynb b/_sources/chap06.ipynb index 21b6641..555bcf8 100644 --- a/_sources/chap06.ipynb +++ b/_sources/chap06.ipynb @@ -640,7 +640,6 @@ ] }, "source": [ - "(section_incremental)=\n", "(section_incremental)=\n", "## Incremental development\n", "\n", @@ -1356,7 +1355,6 @@ ] }, "source": [ - "(section_fibonacci)=\n", "(section_fibonacci)=\n", "## Fibonacci\n", "\n", @@ -1594,7 +1592,6 @@ ] }, "source": [ - "(section_debugging_factorial)=\n", "(section_debugging_factorial)=\n", "## Debugging\n", "\n", @@ -1734,7 +1731,11 @@ "cell_type": "code", "execution_count": 142, "id": "e0f15ca4", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [ { "name": "stdout", @@ -2321,7 +2322,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap07.ipynb b/_sources/chap07.ipynb index baa75fa..08b7f94 100644 --- a/_sources/chap07.ipynb +++ b/_sources/chap07.ipynb @@ -37,7 +37,6 @@ ] }, "source": [ - "(chapter_search)=\n", "(chapter_search)=\n", "# Iteration and Search\n", "\n", @@ -115150,7 +115149,11 @@ "cell_type": "code", "execution_count": null, "id": "bc58db59", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -115821,7 +115824,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap08.ipynb b/_sources/chap08.ipynb index 3b923f0..b187066 100644 --- a/_sources/chap08.ipynb +++ b/_sources/chap08.ipynb @@ -203,7 +203,7 @@ "id": "aec20975", "metadata": { "tags": [ - "raises-excpetion" + "raises-exception" ] }, "outputs": [ @@ -263,7 +263,11 @@ "cell_type": "code", "execution_count": 64, "id": "3ccb4a64", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "IndexError", @@ -595,7 +599,11 @@ "cell_type": "code", "execution_count": 75, "id": "69ccd380", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -847,7 +855,6 @@ ] }, "source": [ - "(section_writing_files)=\n", "(section_writing_files)=\n", "## Writing files\n", "\n", @@ -7049,7 +7056,11 @@ "cell_type": "code", "execution_count": null, "id": "18bced21", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -7450,7 +7461,7 @@ "id": "c1d0f892", "metadata": {}, "source": [ - "## Exercise\n", + "### Exercise\n", "\n", "*The Count of Monte Cristo* is a novel by Alexandre Dumas that is considered a classic.\n", "Nevertheless, in the introduction of an English translation of the book, the writer Umberto Eco confesses that he found the book to be \"one of the most badly written novels of all time\".\n", @@ -7826,7 +7837,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap09.ipynb b/_sources/chap09.ipynb index 8727b21..42daa0b 100644 --- a/_sources/chap09.ipynb +++ b/_sources/chap09.ipynb @@ -248,10 +248,7 @@ "bbox3 = binding3.draw(ax, x+2.25, y-1.0)\n", "\n", "bbox = Bbox.union([bbox1, bbox2, bbox3])\n", - "adjust(x, y, bbox)\n", - "\n", - "import matplotlib.pyplot as plt\n", - "plt.savefig('state_diagram_list.png')" + "#adjust(x, y, bbox)" ] }, { @@ -930,7 +927,11 @@ "cell_type": "code", "execution_count": 33, "id": "861f8e7e", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "ValueError", @@ -1830,7 +1831,6 @@ ] }, "source": [ - "(section_word_list)=\n", "(section_word_list)=\n", "## Making a word list\n", "\n", @@ -2091,7 +2091,11 @@ "cell_type": "code", "execution_count": 70, "id": "97cf0c61", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "AttributeError", @@ -2103,6 +2107,7 @@ } ], "source": [ + "\n", "t.remove(2)" ] }, @@ -2166,7 +2171,11 @@ "cell_type": "code", "execution_count": null, "id": "a4e34564", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -2677,7 +2686,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap10.ipynb b/_sources/chap10.ipynb index f0d60f2..83abb44 100644 --- a/_sources/chap10.ipynb +++ b/_sources/chap10.ipynb @@ -249,7 +249,11 @@ "cell_type": "code", "execution_count": 44, "id": "30c37eef", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "KeyError", @@ -348,9 +352,7 @@ "width, height, x, y = [1.83, 1.24, 0.49, 0.85]\n", "ax = diagram(width, height)\n", "bbox = binding1.draw(ax, x, y)\n", - "# adjust(x, y, bbox)\n", - "#import matplotlib.pyplot as plt\n", - "#plt.savefig('state_diagram_dict.png')" + "# adjust(x, y, bbox)" ] }, { @@ -465,7 +467,6 @@ ] }, "source": [ - "(section_dictionary_in_operator)=\n", "(section_dictionary_in_operator)=\n", "## The in operator\n", "\n", @@ -1151,7 +1152,11 @@ "cell_type": "code", "execution_count": 76, "id": "ca9ff511", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -1194,7 +1199,6 @@ ] }, "source": [ - "(section_palindrome_list)=\n", "(section_palindrome_list)=\n", "## Accumulating a list\n", "\n", @@ -1358,7 +1362,6 @@ ] }, "source": [ - "(section_memos)=\n", "(section_memos)=\n", "## Memos\n", "\n", @@ -1721,7 +1724,11 @@ "cell_type": "code", "execution_count": null, "id": "1e3c12ec", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -2406,7 +2413,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap11.ipynb b/_sources/chap11.ipynb index 58b5405..a720a1d 100644 --- a/_sources/chap11.ipynb +++ b/_sources/chap11.ipynb @@ -37,7 +37,6 @@ ] }, "source": [ - "(chapter_tuples)=\n", "(chapter_tuples)=\n", "# Tuples\n", "\n", @@ -466,7 +465,11 @@ "cell_type": "code", "execution_count": 21, "id": "b4970fe0", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -493,7 +496,11 @@ "cell_type": "code", "execution_count": 22, "id": "772738cc", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "AttributeError", @@ -735,7 +742,11 @@ "cell_type": "code", "execution_count": 30, "id": "8e5b4a14", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "ValueError", @@ -1038,7 +1049,6 @@ ] }, "source": [ - "(section_argument_pack)=\n", "(section_argument_pack)=\n", "## Argument packing\n", "\n", @@ -1101,7 +1111,11 @@ "cell_type": "code", "execution_count": 43, "id": "991810bc", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -1944,7 +1958,6 @@ ] }, "source": [ - "(section_debugging_11)=\n", "(section_debugging_11)=\n", "## Debugging\n", "\n", @@ -2190,7 +2203,11 @@ "cell_type": "code", "execution_count": null, "id": "c65d68d2", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -2300,7 +2317,8 @@ "id": "4fae1acc", "metadata": { "tags": [ - "solution" + "solution", + "raises-exception" ] }, "outputs": [ @@ -2312,7 +2330,10 @@ ] } ], - "source": [] + "source": [ + "\n", + "d = {t: 'this tuple contains two lists'}" + ] }, { "cell_type": "markdown", @@ -2331,7 +2352,6 @@ ] }, "source": [ - "(section_exercise_11)=\n", "(section_exercise_11)=\n", "### Exercise\n", "\n", @@ -3305,7 +3325,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap12.ipynb b/_sources/chap12.ipynb index 2f7010d..f62c003 100644 --- a/_sources/chap12.ipynb +++ b/_sources/chap12.ipynb @@ -126,7 +126,7 @@ "outputs": [], "source": [ "def clean_file(input_file, output_file):\n", - " reader = open(input_file)\n", + " reader = open(input_file, encoding='utf-8')\n", " writer = open(output_file, 'w')\n", "\n", " for line in reader:\n", @@ -825,7 +825,8 @@ "id": "c046117b", "metadata": { "tags": [ - "remove-cell" + "remove-cell", + "raises-exception" ] }, "outputs": [ @@ -853,7 +854,6 @@ ] }, "source": [ - "(section_dictionary_subtraction)=\n", "(section_dictionary_subtraction)=\n", "## Dictionary subtraction\n", "\n", @@ -1185,7 +1185,11 @@ "cell_type": "code", "execution_count": 43, "id": "4fc47ecd", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "KeyError", @@ -2120,7 +2124,6 @@ ] }, "source": [ - "(section_debugging_12)=\n", "(section_debugging_12)=\n", "## Debugging\n", "\n", @@ -2229,7 +2232,11 @@ "cell_type": "code", "execution_count": null, "id": "05752b6d", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -2670,7 +2677,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap13.ipynb b/_sources/chap13.ipynb index 838c2d9..9919ab1 100644 --- a/_sources/chap13.ipynb +++ b/_sources/chap13.ipynb @@ -704,7 +704,8 @@ "id": "26ca3d1b", "metadata": { "tags": [ - "remove-cell" + "remove-cell", + "raises-exception" ] }, "outputs": [ @@ -1293,7 +1294,6 @@ ] }, "source": [ - "(section_storing_data_structure)=\n", "(section_storing_data_structure)=\n", "## Storing data structures\n", "\n", @@ -1561,7 +1561,6 @@ ] }, "source": [ - "(section_md5_digest)=\n", "(section_md5_digest)=\n", "## Checking for equivalent files\n", "\n", @@ -1814,7 +1813,6 @@ ] }, "source": [ - "(section_walking_directories)=\n", "(section_walking_directories)=\n", "## Walking directories\n", "\n", @@ -2087,7 +2085,11 @@ "cell_type": "code", "execution_count": null, "id": "bd885ba1", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -2578,7 +2580,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap14.ipynb b/_sources/chap14.ipynb index 9dcb4d4..53d3a58 100644 --- a/_sources/chap14.ipynb +++ b/_sources/chap14.ipynb @@ -1377,7 +1377,6 @@ ] }, "source": [ - "(section_debugging_14)=\n", "(section_debugging_14)=\n", "## Debugging\n", "\n", @@ -1596,7 +1595,11 @@ "cell_type": "code", "execution_count": null, "id": "ab3d0104", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -2131,7 +2134,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap15.ipynb b/_sources/chap15.ipynb index 5ee8065..d77c43f 100644 --- a/_sources/chap15.ipynb +++ b/_sources/chap15.ipynb @@ -988,7 +988,11 @@ "cell_type": "code", "execution_count": 35, "id": "56680d97", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "AssertionError", @@ -1056,7 +1060,11 @@ "cell_type": "code", "execution_count": null, "id": "3115ea33", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -1260,7 +1268,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap16.ipynb b/_sources/chap16.ipynb index 290cf6a..bfcb6eb 100644 --- a/_sources/chap16.ipynb +++ b/_sources/chap16.ipynb @@ -54,7 +54,6 @@ ] }, "source": [ - "(section_create_point)=\n", "(section_create_point)=\n", "## Creating a Point\n", "\n", @@ -1672,7 +1671,11 @@ "cell_type": "code", "execution_count": null, "id": "32b151a5", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -2728,7 +2731,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap17.ipynb b/_sources/chap17.ipynb index 0e8614c..d689115 100644 --- a/_sources/chap17.ipynb +++ b/_sources/chap17.ipynb @@ -37,7 +37,6 @@ ] }, "source": [ - "(chapter_inheritance)=\n", "(chapter_inheritance)=\n", "# Inheritance\n", "\n", @@ -689,7 +688,11 @@ "cell_type": "code", "execution_count": 22, "id": "aa63fe2a", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -1047,7 +1050,6 @@ ] }, "source": [ - "(section_print_deck)=\n", "(section_print_deck)=\n", "## Printing the deck\n", "\n", @@ -1911,7 +1913,11 @@ "cell_type": "code", "execution_count": null, "id": "e281457a", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -3350,7 +3356,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap18.ipynb b/_sources/chap18.ipynb index eb18c6b..20531c9 100644 --- a/_sources/chap18.ipynb +++ b/_sources/chap18.ipynb @@ -1973,7 +1973,11 @@ "cell_type": "code", "execution_count": 72, "id": "e61693ba", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -1993,7 +1997,11 @@ "cell_type": "code", "execution_count": 73, "id": "871dafae", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "AttributeError", @@ -2102,7 +2110,11 @@ "cell_type": "code", "execution_count": 77, "id": "5871229d", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -2269,7 +2281,11 @@ "cell_type": "code", "execution_count": 83, "id": "ba91298b", - "metadata": {}, + "metadata": { + "tags": [ + "raises-exception" + ] + }, "outputs": [ { "ename": "TypeError", @@ -2579,7 +2595,11 @@ "cell_type": "code", "execution_count": null, "id": "5029c76d", - "metadata": {}, + "metadata": { + "tags": [ + "remove-print" + ] + }, "outputs": [], "source": [ "# This cell tells Jupyter to provide detailed debugging information\n", @@ -3319,7 +3339,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.10.14" } }, "nbformat": 4, diff --git a/_sources/chap19.ipynb b/_sources/chap19.ipynb new file mode 100644 index 0000000..ac1fcae --- /dev/null +++ b/_sources/chap19.ipynb @@ -0,0 +1,162 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "171aca73", + "metadata": {}, + "source": [ + "# Final thoughts" + ] + }, + { + "cell_type": "markdown", + "id": "4d551c99", + "metadata": {}, + "source": [ + "Learning to program is not easy, but if you made it this far, you are off to a good start.\n", + "Now I have some suggestions for ways you can keep learning and apply what you have learned.\n", + "\n", + "This book is meant to be a general introduction to programming, so we have not focused on specific applications.\n", + "Depending on your interests, there are any number of areas where you can apply your new skills.\n", + "\n", + "If you are interested in Data Science, there are three books of mine you might like:\n", + "\n", + "* *Think Stats: Exploratory Data Analysis*, O'Reilly Media, 2014.\n", + "\n", + "* *Think Bayes: Bayesian Statistics in Python*, O'Reilly Media, 2021.\n", + "\n", + "* *Think DSP: Digital Signal Processing in Python*, O'Reilly Media, 2016." + ] + }, + { + "cell_type": "markdown", + "id": "cceabe36", + "metadata": {}, + "source": [ + "If you are interested in physical modeling and complex systems, you might like:\n", + "\n", + "* *Modeling and Simulation in Python: An Introduction for Scientists and Engineers*, No Starch Press, 2023.\n", + "\n", + "* *Think Complexity: Complexity Science and Computational Modeling*, O'Reilly Media, 2018.\n", + "\n", + "These use NumPy, SciPy, pandas, and other Python libraries for data science and scientific computing." + ] + }, + { + "cell_type": "markdown", + "id": "54a39121", + "metadata": {}, + "source": [ + "This book tries to find a balance between general principles of programming and details of Python.\n", + "As a result, it does not include every feature of the Python language.\n", + "For more about Python, and good advice about how to use it, I recommend *Fluent Python: Clear, Concise, and Effective Programming*, second edition by Luciano Ramalho, O'Reilly Media, 2022.\n", + "\n", + "After an introduction to programming, a common next step is to learn about data structures and algorithms.\n", + "I have a work in progress on this topic, called *Data Structures and Information Retrieval in Python*.\n", + "A free electronic version is available from Green Tea Press at ." + ] + }, + { + "cell_type": "markdown", + "id": "a1598510", + "metadata": {}, + "source": [ + "As you work on more complex programs, you will encounter new challenges.\n", + "You might find it helpful to review the sections in this book about debugging.\n", + "In particular, remember the Five R's of debugging from [Chapter 12](section_debugging_12): reading, running, ruminating, rubber-ducking, and retreating.\n", + "\n", + "This book suggests tools to help with debugging, including the `print` and `repr` functions, the `structshape` function in [Chapter 11](section_debugging_11) -- and the built-in functions `isinstance`, `hasattr`, and `vars` in [Chapter 14](section_debugging_14)." + ] + }, + { + "cell_type": "markdown", + "id": "fb4dd345", + "metadata": {}, + "source": [ + "It also suggests tools for testing programs, including the `assert` statement, the `doctest` module, and the `unittest` module.\n", + "Including tests in your programs is one of the best ways to prevent and detect errors, and save time debugging.\n", + "\n", + "But the best kind of debugging is the kind you don't have to do.\n", + "If you use an incremental development process as described in [Chapter 6](section_incremental) -- and test as you go -- you will make fewer errors and find them more quickly when you do.\n", + "Also, remember encapsulation and generalization from [Chapter 4](section_encapsulation), which is particularly useful when you are developing code in Jupyter notebooks." + ] + }, + { + "cell_type": "markdown", + "id": "0d29933e", + "metadata": {}, + "source": [ + "Throughout this book, I've suggested ways to use virtual assistants to help you learn, program, and debug.\n", + "I hope you are finding these tools useful.\n", + "\n", + "In additional to virtual assistants like ChatGPT, you might also want to use a tool like Copilot that autocompletes code as you type.\n", + "I did not recommend using these tools, initially, because they can be overwhelming for beginners.\n", + "But you might want to explore them now.\n", + "\n", + "Using AI tools effectively requires some experimentation and reflection to find a flow that works for you.\n", + "If you think it's a nuisance to copy code from ChatGPT to Jupyter, you might prefer something like Copilot.\n", + "But the cognitive work you do to compose a prompt and interpret the response can be as valuable as the code the tool generates, in the same vein as rubber duck debugging." + ] + }, + { + "cell_type": "markdown", + "id": "c28d6815", + "metadata": {}, + "source": [ + "As you gain programming experience, you might want to explore other development environments.\n", + "I think Jupyter notebooks are a good place to start, but they are relatively new and not as widely-used as conventional integrated development environments (IDE).\n", + "For Python, the most popular IDEs include PyCharm and Spyder -- and Thonny, which is often recommended for beginners.\n", + "Other IDEs, like Visual Studio Code and Eclipse, work with other programming languages as well.\n", + "Or, as a simpler alternative, you can write Python programs using any text editor you like.\n", + "\n", + "As you continue your programming journey, you don't have to go alone!\n", + "If you live in or near a city, there's a good chance there is a Python user group you can join.\n", + "These groups are usually friendly to beginners, so don't be afraid.\n", + "If there is no group near you, you might be able to join events remotely.\n", + "Also, keep an eye out for regional Python conferences." + ] + }, + { + "cell_type": "markdown", + "id": "28cb22bf", + "metadata": {}, + "source": [ + "One of the best ways to improve your programming skills is to learn another language.\n", + "If you are interested in statistics and data science, you might want to learn R.\n", + "But I particularly recommend learning a functional language like Racket or Elixir.\n", + "Functional programming requires a different kind of thinking, which changes the way you think about programs.\n", + "\n", + "Good luck!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e2783577", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/chap00.html b/chap00.html index e0d24b3..22ee639 100644 --- a/chap00.html +++ b/chap00.html @@ -170,6 +170,7 @@
  • Classes and Objects
  • Inheritance
  • Python Extras
  • +
  • Final thoughts
  • diff --git a/chap01.html b/chap01.html index 940f266..3d2d62c 100644 --- a/chap01.html +++ b/chap01.html @@ -170,6 +170,7 @@
  • Classes and Objects
  • Inheritance
  • Python Extras
  • +
  • Final thoughts
  • @@ -342,9 +343,9 @@

    Contents

  • Exercises
  • @@ -359,7 +360,7 @@

    Contents

    -

    Programming as a way of thinking#

    +

    Programming as a way of thinking#

    The first goal of this book is to teach you how to program in Python. But learning to program means learning a new way to think, so the second goal of this book is to help you think like a computer scientist. This way of thinking combines some of the best features of mathematics, engineering, and natural science. @@ -1001,7 +1002,7 @@

    Glossary

    Exercises#

    -
    +
    # This cell tells Jupyter to provide detailed debugging information
     # when a runtime error occurs. Run it before working on the exercises.
    @@ -1061,8 +1062,8 @@ 

    Exercise -

    Exercise#

    +
    +

    Exercise#

    When you learn about a new feature, you should try it out and make mistakes on purpose. That way, you learn the error messages, and when you see them again, you will know what they mean. It is better to make mistakes now and deliberately than later and accidentally.

    @@ -1072,8 +1073,8 @@

    Exercise
  • If you call a function like round(42.5), what happens if you leave out one or both parentheses?

  • -
    -

    Exercise#

    +
    +

    Exercise#

    Recall that every expression has a value, every value has a type, and we can use the type function to find the type of any value.

    What is the type of the value of the following expressions? Make your best guess for each one, and then use type to find out.

      @@ -1087,8 +1088,8 @@

      Exercise
    • type

    -
    -

    Exercise#

    +
    +

    Exercise#

    The following questions give you a chance to practice writing arithmetic expressions.

    1. How many seconds are there in 42 minutes 42 seconds?

    2. @@ -1181,9 +1182,9 @@

      Exercise
    3. Exercises
    4. diff --git a/chap02.html b/chap02.html index 6f6c617..0403526 100644 --- a/chap02.html +++ b/chap02.html @@ -172,6 +172,7 @@
    5. Classes and Objects
    6. Inheritance
    7. Python Extras
    8. +
    9. Final thoughts

    @@ -966,7 +967,7 @@

    Glossary

    Exercises#

    -
    +
    # This cell tells Jupyter to provide detailed debugging information
     # when a runtime error occurs. Run it before working on the exercises.
    diff --git a/chap03.html b/chap03.html
    index 755a681..fd82694 100644
    --- a/chap03.html
    +++ b/chap03.html
    @@ -170,6 +170,7 @@
     
  • Classes and Objects
  • Inheritance
  • Python Extras
  • +
  • Final thoughts
  • @@ -746,6 +747,21 @@

    Tracebackscat_twice.

    +
    +
    +
    # This cell tells Jupyter to provide detailed debugging information
    +# when a runtime error occurs, including a traceback.
    +
    +%xmode Verbose
    +
    +
    +
    +
    +
    Exception reporting mode: Plain
    +
    +
    +
    +
    cat_twice(line1, line2)
    @@ -832,7 +848,7 @@ 

    Glossary

    Exercises#

    -
    +
    # This cell tells Jupyter to provide detailed debugging information
     # when a runtime error occurs. Run it before working on the exercises.
    @@ -892,20 +908,6 @@ 

    Exercise

    Write a function called triangle that takes a string and an integer and draws a pyramid with the given height, made up using copies of the string. Here’s an example of a pyramid with 4 levels, using the string 'L'.

    -
    def triangle(string, height):
    -    """Make a triangle shape by printing a string repeatedly.
    -    
    -    string: characters to be repeated
    -    height: number of lines in the triangle
    -    """
    -    for i in range(height+1):
    -        print(string * i)
    -
    -
    -
    -
    -
    -
    triangle('L', 5)
     
    @@ -926,21 +928,6 @@

    Exercise

    Write a function called rectangle that takes a string and two integers and draws a rectangle with the given height and width, made up using copies of the string. Here’s an example of a pyramid with 4 levels, using the string 'L'.

    -
    def rectangle(string, width, height):
    -    """Make a rectangle by printing a string repeatedly.
    -    
    -    string: characters to be repeated
    -    width: number of repetitions on each line
    -    height: number of lines
    -    """
    -    for i in range(height+1):
    -        print(string * width)
    -
    -
    -
    -
    -
    - @@ -345,10 +346,10 @@

    Contents

  • Exercise
  • -
  • Exercise
  • -
    -

    Exercise#

    +
    +

    Exercise#

    Write an appropriately general set of functions that can draw flowers like this.

    Hint: Use arc to write a function called petal that draws one flower petal.

    @@ -3497,10 +3498,10 @@

    Ask a virtual assistantExercise -
  • Exercise
  • @@ -1153,7 +1154,7 @@

    Glossary

    Exercises#

    -
    +
    # This cell tells Jupyter to provide detailed debugging information
     # when a runtime error occurs. Run it before working on the exercises.
    diff --git a/chap06.html b/chap06.html
    index d884228..b913f84 100644
    --- a/chap06.html
    +++ b/chap06.html
    @@ -172,6 +172,7 @@
     
  • Classes and Objects
  • Inheritance
  • Python Extras
  • +
  • Final thoughts
  • @@ -347,9 +348,9 @@

    Contents

  • Exercises
  • @@ -653,7 +654,7 @@

    Return values and conditionals -

    Incremental development#

    +

    Incremental development#

    As you write larger functions, you might find yourself spending more time debugging. To deal with increasingly complex programs, you might want to try incremental development, which is a way of adding and testing only a small amount of code at a time.

    @@ -1006,7 +1007,7 @@

    Leap of faith -

    Fibonacci#

    +

    Fibonacci#

    After factorial, the most common example of a recursive function is fibonacci, which has the following definition:

    Checking types#

    @@ -1131,7 +1132,7 @@

    Checking types -

    Debugging#

    +

    Debugging#

    Breaking a large program into smaller functions creates natural checkpoints for debugging. If a function is not working, there are three possibilities to consider:

    -
    -

    Exercise#

    +
    +

    Exercise#

    Write a boolean function, is_between(x, y, z), that returns True if \(x < y < z\) or if \(z < y < x\), andFalse otherwise.

    -
    -

    Exercise#

    +
    +

    Exercise#

    The Ackermann function, \(A(m, n)\), is defined:

    -
    -

    Exercise#

    +
    +

    Exercise#

    The greatest common divisor (GCD) of \(a\) and \(b\) is the largest number that divides both of them with no remainder.

    One way to find the GCD of two numbers is based on the observation that @@ -1387,9 +1388,9 @@

    Exercise
  • Exercises
  • diff --git a/chap07.html b/chap07.html index 49bae32..f2b87e1 100644 --- a/chap07.html +++ b/chap07.html @@ -170,6 +170,7 @@
  • Classes and Objects
  • Inheritance
  • Python Extras
  • +
  • Final thoughts
  • @@ -342,12 +343,12 @@

    Contents

  • Exercises
  • @@ -362,7 +363,7 @@

    Contents