Skip to content

Commit

Permalink
Small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Sep 20, 2022
1 parent de13910 commit 74a567b
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 326 deletions.
2 changes: 1 addition & 1 deletion 00 Part IA Michaelmas Term computing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.14"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions 01 Variables, assignment and operator precedence.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"['False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']\n"
"['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']\n"
]
}
],
Expand Down Expand Up @@ -747,7 +747,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.14"
"version": "3.10.6"
},
"toc-autonumbering": true
},
Expand Down
4 changes: 2 additions & 2 deletions 02 Control statements.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@
"A common bug, especially when using `while` statements, is the [infinite loop](https://en.wikipedia.org/wiki/Infinite_loop). This is when a loop is entered but never terminates (exits).\n",
"Infinite loops can render a system unresponsive, sometimes requiring a shutdown to restore function.\n",
"\n",
"It is good practice, espeically when learning, to add guards against infinite loops. For example, "
"It is good practice to add guards against infinite loops. For example, "
]
},
{
Expand Down Expand Up @@ -1082,7 +1082,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.14"
"version": "3.10.6"
},
"toc-autonumbering": true,
"toc-showmarkdowntxt": false,
Expand Down
21 changes: 10 additions & 11 deletions 03 Types, type conversions and floating point arithmetic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Patriot Missile failure and the Ariane 5 explosion\n",
"### Ariane 5 explosion and Patriot Missile failure\n",
"\n",
"There have been numerous accidents due to programs not correctly handling types, type conversions and floating point arithmetic. Here are two examples: \n",
"\n",
"1. Poor programming related to how computers store numbers led in 1996 to a European Space Agency *Ariane 5* \n",
" unmanned rocket exploding shortly after lift-off. The rocket payload, worth US\\$500 M,\n",
" was destroyed. You can find background at https://en.wikipedia.org/wiki/Cluster_(spacecraft)#Launch_failure. \n",
" We will reproduce the mistake, and show how a few lines code would have saved over US\\$500 M. \n",
" \n",
" <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Ariane_5ES_with_ATV_4_on_its_way_to_ELA-3.jpg/320px-Ariane_5ES_with_ATV_4_on_its_way_to_ELA-3.jpg\" width=\"200\" />\n",
" \n",
"1. In 1991, a US Patriot missile failed to intercept an Iraqi Scud missile at Dhahran in Saudi Arabi, leading to \n",
" a loss of life. The subsequent investigation found that the Patriot missile failed to intercept the Scud \n",
" missile due to a software flaw. The software developers did not account for the effects of 'floating point \n",
Expand All @@ -41,15 +48,7 @@
"\n",
" We will reproduce the precise mistake the developers of the Patriot Missile software made. See\n",
" https://en.wikipedia.org/wiki/MIM-104_Patriot#Failure_at_Dhahran for more background on the interception \n",
" failure.\n",
" \n",
"\n",
"2. Poor programming related to how computers store numbers led in 1996 to a European Space Agency *Ariane 5* \n",
" unmanned rocket exploding shortly after lift-off. The rocket payload, worth US\\$500 M,\n",
" was destroyed. You can find background at https://en.wikipedia.org/wiki/Cluster_(spacecraft)#Launch_failure. \n",
" We will reproduce the mistake, and show how a few lines code would have saved over US\\$500 M. \n",
" \n",
" <img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Ariane_5ES_with_ATV_4_on_its_way_to_ELA-3.jpg/320px-Ariane_5ES_with_ATV_4_on_its_way_to_ELA-3.jpg\" width=\"200\" />"
" failure."
]
},
{
Expand Down Expand Up @@ -1558,7 +1557,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.14"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions 04 Functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
],
"source": [
"def sum_and_increment(a, b):\n",
" \"\"\"\"Return the sum of a and b, plus 1\"\"\"\n",
" \"\"\"Return the sum of a and b, plus 1\"\"\"\n",
" return a + b + 1\n",
"\n",
"# Call the function\n",
Expand Down Expand Up @@ -73,8 +73,8 @@
"- Next comes the body of the function. The first part of the body is indented four spaces. \n",
" Everything that makes \n",
" up the body of the function is indented at least four spaces relative to `def`. \n",
" In Python, the first part of the body is an optional documentation string that describes in words what the \n",
" function does \n",
" In Python, the first part of the body is an optional documentation string that describes in words \n",
" what the function does \n",
" ```python \n",
" \"Return the sum of a and b, plus 1\"\n",
" ```\n",
Expand Down Expand Up @@ -731,7 +731,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.14"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
10 changes: 4 additions & 6 deletions 05 Library functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Renaming functions at import can be helpful to keep code short, and we will see below it can be useful for switching between different functions.\n",
"However the above choice of name is very poor practice - the name '`some_math_function`' is not descriptive.\n",
"Below is a more sensible example."
"Renaming functions at import can be helpful to keep code short, and we will see below it can be useful for switching between different functions."
]
},
{
Expand Down Expand Up @@ -750,7 +748,7 @@
" tau = 6.283185307179586\n",
"\n",
"FILE\n",
" /usr/local/Cellar/python@3.9/3.9.14/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/math.cpython-39-darwin.so\n",
" /opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/math.cpython-310-darwin.so\n",
"\n",
"\n"
]
Expand Down Expand Up @@ -783,7 +781,7 @@
"slightly faster than the normalvariate() function.\n",
"\n",
"Not thread-safe without a lock around calls.\n",
"\u001b[0;31mFile:\u001b[0m /usr/local/Cellar/python@3.9/3.9.14/Frameworks/Python.framework/Versions/3.9/lib/python3.9/random.py\n",
"\u001b[0;31mFile:\u001b[0m /opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/random.py\n",
"\u001b[0;31mType:\u001b[0m method\n"
]
},
Expand Down Expand Up @@ -822,7 +820,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.14"
"version": "3.10.6"
},
"toc-autonumbering": true
},
Expand Down
Loading

0 comments on commit 74a567b

Please sign in to comment.