Skip to content

Commit 669480f

Browse files
Rewrite exercise 4.4 and fix numbering exercise notebook 7
1 parent 8801aeb commit 669480f

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

book/exercise_notebooks/exercise_notebook_4_debugging.ipynb

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,29 @@
107107
}
108108
},
109109
"source": [
110-
"<div class=\"alert alert-block alert-info\"><b>(Fixing) Exercise 4.4 </b><br><br><div style=\"text-align: justify\">Find the semantic error in this function.\n",
110+
"<div class=\"alert alert-block alert-info\"><b>(Fixing) Exercise 4.4 </b><br><br><div style=\"text-align: justify\">\n",
111111
"\n",
112-
"Hint: The factorial n! is defined as <code>n! = n * (n - 1) * (n - 2) * ... * 2 * 1</code>. The function uses the fact that if n > 0, <code>n! = n * (n - 1)!</code>. This is an example of a _recursive_ function, a function that calls itself.</div></div>"
112+
"The factorial n! is defined as <code>n! = n * (n - 1) * (n - 2) * ... * 2 * 1</code>. The function uses the fact that if n > 0, <code>n! = n * (n - 1)!</code>. This is an example of a _recursive_ function, a function that calls itself.</div></div>\n",
113+
"\n",
114+
"The code below calls the function \"factorial\" with the number 4 as input. The factorial of 4 is <code>4 * 3 * 2 * 1</code>, which is 24, but the code below prints 262144. Find and fix the semantic error in this function."
113115
]
114116
},
115117
{
116118
"cell_type": "code",
117-
"execution_count": null,
119+
"execution_count": 5,
118120
"metadata": {},
119-
"outputs": [],
121+
"outputs": [
122+
{
123+
"data": {
124+
"text/plain": [
125+
"262144"
126+
]
127+
},
128+
"execution_count": 5,
129+
"metadata": {},
130+
"output_type": "execute_result"
131+
}
132+
],
120133
"source": [
121134
"def factorial(x):\n",
122135
" \"returns the factorial of x\"\n",
@@ -138,7 +151,7 @@
138151
],
139152
"metadata": {
140153
"kernelspec": {
141-
"display_name": "Python 3 (ipykernel)",
154+
"display_name": "base",
142155
"language": "python",
143156
"name": "python3"
144157
},
@@ -152,7 +165,7 @@
152165
"name": "python",
153166
"nbconvert_exporter": "python",
154167
"pygments_lexer": "ipython3",
155-
"version": "3.10.0"
168+
"version": "3.12.7"
156169
},
157170
"latex_envs": {
158171
"LaTeX_envs_menu_present": true,
@@ -171,11 +184,6 @@
171184
"latex_user_defs": false,
172185
"report_style_numbering": false,
173186
"user_envs_cfg": false
174-
},
175-
"vscode": {
176-
"interpreter": {
177-
"hash": "1fe2f2b718b1108b9c4176932db8a0ead471245140baaa21ea96a4066683e6b2"
178-
}
179187
}
180188
},
181189
"nbformat": 4,

book/exercise_notebooks/exercise_notebook_7_files.ipynb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,7 @@
1414
" <IMG SRC=\"https://raw.githubusercontent.com/mbakker7/exploratory_computing_with_python/master/tudelft_logo.png\" WIDTH=250 ALIGN=\"right\">\n",
1515
"</figure>\n",
1616
"\n",
17-
"# Exercise Notebook 6 - Python files"
18-
]
19-
},
20-
{
21-
"cell_type": "markdown",
22-
"metadata": {},
23-
"source": [
24-
"This week, please hand in your exercise as `.py` files, not notebooks.\n",
25-
"See the course material for how to work with .py files. You should submit three .py files in Brightspace.\n",
26-
"\n",
27-
"Name your files according to this template:\n",
28-
"\n",
29-
"`Notebook7_Group_<N>_<exericse number>.py`"
17+
"# Exercise Notebook 7 - Python files"
3018
]
3119
},
3220
{

0 commit comments

Comments
 (0)