Skip to content

Commit ed48a3c

Browse files
committed
Small fixes to labs/lectures
1 parent e9419fb commit ed48a3c

6 files changed

Lines changed: 215 additions & 101 deletions

File tree

‎Week_0_python/Intro_assignment.ipynb‎

Lines changed: 100 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 2,
66
"metadata": {
77
"deletable": false,
88
"editable": false
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"cell_type": "code",
39-
"execution_count": null,
39+
"execution_count": 3,
4040
"metadata": {},
4141
"outputs": [],
4242
"source": [
@@ -68,7 +68,19 @@
6868
"otter_answer_cell"
6969
]
7070
},
71-
"outputs": [],
71+
"outputs": [
72+
{
73+
"ename": "AssertionError",
74+
"evalue": "",
75+
"output_type": "error",
76+
"traceback": [
77+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
78+
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
79+
"Cell \u001b[0;32mIn[4], line 12\u001b[0m\n\u001b[1;32m 9\u001b[0m data_file_name \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;241m.\u001b[39m\n\u001b[1;32m 11\u001b[0m \u001b[38;5;66;03m# This is what the autograder will check\u001b[39;00m\n\u001b[0;32m---> 12\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m data_file_name \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata1.csv\u001b[39m\u001b[38;5;124m\"\u001b[39m\n",
80+
"\u001b[0;31mAssertionError\u001b[0m: "
81+
]
82+
}
83+
],
7284
"source": [
7385
"# GUIDE: Create a string from the following variables\n",
7486
"\n",
@@ -80,6 +92,7 @@
8092
"# GUIDE: replace ... with string creation\n",
8193
"data_file_name = ...\n",
8294
"\n",
95+
"print(f\"{data_file_name}, {da}\")\n",
8396
"# This is what the autograder will check\n",
8497
"assert data_file_name == \"data1.csv\""
8598
]
@@ -119,12 +132,93 @@
119132
},
120133
{
121134
"cell_type": "code",
122-
"execution_count": null,
135+
"execution_count": 5,
123136
"metadata": {
124137
"deletable": false,
125138
"editable": false
126139
},
127-
"outputs": [],
140+
"outputs": [
141+
{
142+
"data": {
143+
"text/html": [
144+
"<p><strong style='color: red;'><pre style='display: inline;'>Strings</pre> results:</strong></p><p><strong><pre style='display: inline;'>Strings - 1</pre> result:</strong></p><pre> ❌ Test case failed\n",
145+
" Trying:\n",
146+
" assert data_file_name == 'data1.csv'\n",
147+
" Expecting nothing\n",
148+
" **********************************************************************\n",
149+
" Line 1, in Strings 0\n",
150+
" Failed example:\n",
151+
" assert data_file_name == 'data1.csv'\n",
152+
" Exception raised:\n",
153+
" Traceback (most recent call last):\n",
154+
" File \"/opt/anaconda3/lib/python3.12/doctest.py\", line 1368, in __run\n",
155+
" exec(compile(example.source, filename, \"single\",\n",
156+
" File \"<doctest Strings 0[0]>\", line 1, in <module>\n",
157+
" assert data_file_name == 'data1.csv'\n",
158+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
159+
" AssertionError\n",
160+
"</pre><p><strong><pre style='display: inline;'>Strings - 2</pre> result:</strong></p><pre> ❌ Test case failed\n",
161+
" Trying:\n",
162+
" assert new_file_name == 'fname1.csv'\n",
163+
" Expecting nothing\n",
164+
" **********************************************************************\n",
165+
" Line 1, in Strings 1\n",
166+
" Failed example:\n",
167+
" assert new_file_name == 'fname1.csv'\n",
168+
" Exception raised:\n",
169+
" Traceback (most recent call last):\n",
170+
" File \"/opt/anaconda3/lib/python3.12/doctest.py\", line 1368, in __run\n",
171+
" exec(compile(example.source, filename, \"single\",\n",
172+
" File \"<doctest Strings 1[0]>\", line 1, in <module>\n",
173+
" assert new_file_name == 'fname1.csv'\n",
174+
" ^^^^^^^^^^^^^\n",
175+
" NameError: name 'new_file_name' is not defined. Did you mean: 'data_file_name'?\n",
176+
"</pre>"
177+
],
178+
"text/plain": [
179+
"Strings results:\n",
180+
" Strings - 1 result:\n",
181+
" ❌ Test case failed\n",
182+
" Trying:\n",
183+
" assert data_file_name == 'data1.csv'\n",
184+
" Expecting nothing\n",
185+
" **********************************************************************\n",
186+
" Line 1, in Strings 0\n",
187+
" Failed example:\n",
188+
" assert data_file_name == 'data1.csv'\n",
189+
" Exception raised:\n",
190+
" Traceback (most recent call last):\n",
191+
" File \"/opt/anaconda3/lib/python3.12/doctest.py\", line 1368, in __run\n",
192+
" exec(compile(example.source, filename, \"single\",\n",
193+
" File \"<doctest Strings 0[0]>\", line 1, in <module>\n",
194+
" assert data_file_name == 'data1.csv'\n",
195+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
196+
" AssertionError\n",
197+
"\n",
198+
" Strings - 2 result:\n",
199+
" ❌ Test case failed\n",
200+
" Trying:\n",
201+
" assert new_file_name == 'fname1.csv'\n",
202+
" Expecting nothing\n",
203+
" **********************************************************************\n",
204+
" Line 1, in Strings 1\n",
205+
" Failed example:\n",
206+
" assert new_file_name == 'fname1.csv'\n",
207+
" Exception raised:\n",
208+
" Traceback (most recent call last):\n",
209+
" File \"/opt/anaconda3/lib/python3.12/doctest.py\", line 1368, in __run\n",
210+
" exec(compile(example.source, filename, \"single\",\n",
211+
" File \"<doctest Strings 1[0]>\", line 1, in <module>\n",
212+
" assert new_file_name == 'fname1.csv'\n",
213+
" ^^^^^^^^^^^^^\n",
214+
" NameError: name 'new_file_name' is not defined. Did you mean: 'data_file_name'?"
215+
]
216+
},
217+
"execution_count": 5,
218+
"metadata": {},
219+
"output_type": "execute_result"
220+
}
221+
],
128222
"source": [
129223
"grader.check(\"Strings\")"
130224
]
@@ -353,7 +447,7 @@
353447
"name": "python",
354448
"nbconvert_exporter": "python",
355449
"pygments_lexer": "ipython3",
356-
"version": "3.11.7"
450+
"version": "3.12.4"
357451
},
358452
"otter": {
359453
"OK_FORMAT": true,
Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,84 @@
11
{
2-
"cells": [
3-
{
4-
"cell_type": "markdown",
5-
"metadata": {},
6-
"source": [
7-
"## Ensuring the libararies are installed correctly\n",
8-
"\n",
9-
"Use this JN to check that all your libraries are installed correctly, and to install any that are not.\n",
10-
"\n",
11-
"First thing to note: See the \"Select Kernel\" in the upper-right hand corner? This needs to be set to the Python version you setup in the instructions:\n",
12-
"\n",
13-
"https://docs.google.com/document/d/1Cp4uuRHMWHfKTAbYAV14y2tMWslmj_-bv_xo3CxYGAo/edit?usp=sharing\n",
14-
"\n",
15-
"Presumably, if you are reading this, than you have already set up VSCode and done the library installs in the above document. \n",
16-
"\n",
17-
"Note: If you are using this file to \"fix\" library problems, first make sure that whatever you've selected in \"Select Kernel\" is the same for both JNs. \n"
18-
]
19-
},
20-
{
21-
"cell_type": "code",
22-
"execution_count": null,
23-
"metadata": {},
24-
"outputs": [],
25-
"source": [
26-
"# These are all the imports you'll need in the class; if you get a \"library not found\" then see the following cells for installing them\n",
27-
"\n",
28-
"# Note: You may get a pop-up that says \"ipykernel needed, install y/n\". Say yes. That's the library that lets you run cells in a JN.\n",
29-
"# For Mac users with Apple silicon: That install will likely Fail - you will need to follow the instructions to over-ride the\n",
30-
"# system checks (at least as-of spring 2025). Go back to the install doc (above) and follow the instructions for how to do that.\n",
31-
"# If you've already done it, then chances are that when you did Select Kernel you did not pick the same kernel as the one you\n",
32-
"# did the homebrew install with. Double check that they are the same by typing \"python3 --version\" into a terminal - that one\n",
33-
"# should be the same as the one you picked for Select Kernel\n",
34-
"import otter\n",
35-
"import numpy\n",
36-
"import matplotlib\n",
37-
"import scipy\n",
38-
"import json"
39-
]
40-
},
41-
{
42-
"cell_type": "markdown",
43-
"metadata": {},
44-
"source": [
45-
"If all of the above imports worked, then you're done! If not, you can use the following cell to force-install the missing libraries\n",
46-
"\n",
47-
"This may take awhile, btw"
48-
]
49-
},
50-
{
51-
"cell_type": "code",
52-
"execution_count": null,
53-
"metadata": {},
54-
"outputs": [],
55-
"source": [
56-
"import sys\n",
57-
"!{sys.executable} -m pip install otter-grader\n",
58-
"!{sys.executable} -m pip install numpy\n",
59-
"!{sys.executable} -m pip install matplotlib\n",
60-
"!{sys.executable} -m pip install scipy\n",
61-
"!{sys.executable} -m pip install json"
62-
]
63-
}
64-
],
65-
"metadata": {
66-
"kernelspec": {
67-
"display_name": "base",
68-
"language": "python",
69-
"name": "python3"
70-
},
71-
"language_info": {
72-
"codemirror_mode": {
73-
"name": "ipython",
74-
"version": 3
75-
},
76-
"file_extension": ".py",
77-
"mimetype": "text/x-python",
78-
"name": "python",
79-
"nbconvert_exporter": "python",
80-
"pygments_lexer": "ipython3",
81-
"version": "3.11.7"
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## Ensuring the libararies are installed correctly\n",
8+
"\n",
9+
"Use this JN to check that all your libraries are installed correctly, and to install any that are not.\n",
10+
"\n",
11+
"First thing to note: See the \"Select Kernel\" in the upper-right hand corner? This needs to be set to the Python version you setup in the instructions:\n",
12+
"\n",
13+
"https://docs.google.com/document/d/1Cp4uuRHMWHfKTAbYAV14y2tMWslmj_-bv_xo3CxYGAo/edit?usp=sharing\n",
14+
"\n",
15+
"Presumably, if you are reading this, than you have already set up VSCode and done the library installs in the above document. \n",
16+
"\n",
17+
"Note: If you are using this file to \"fix\" library problems, first make sure that whatever you've selected in \"Select Kernel\" is the same for both JNs. \n"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": null,
23+
"metadata": {},
24+
"outputs": [],
25+
"source": [
26+
"# These are all the imports you'll need in the class; if you get a \"library not found\" then see the following cells for installing them\n",
27+
"\n",
28+
"# Note: If you get a pop-up that says \"ipykernel needed, install y/n\" and you've run either the windows_install.bat or mac_install.sh,\n",
29+
"# chances are the problem is actually that you opened the wrong folder. If you look in the upper left it should say Intro or ROB456 or ROB514\n",
30+
"# - it should not say GIT. \n",
31+
"# If you have not run the installs, do so - but you can also just say yes and then do the cell below.\n",
32+
"import otter\n",
33+
"import numpy\n",
34+
"import matplotlib\n",
35+
"import scipy\n",
36+
"import json"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
43+
"If all of the above imports worked, then you're done! If not, you can use the following cell to force-install the missing libraries\n",
44+
"\n",
45+
"This may take awhile, btw"
46+
]
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": null,
51+
"metadata": {},
52+
"outputs": [],
53+
"source": [
54+
"import sys\n",
55+
"!{sys.executable} -m pip install otter-grader\n",
56+
"!{sys.executable} -m pip install numpy\n",
57+
"!{sys.executable} -m pip install matplotlib\n",
58+
"!{sys.executable} -m pip install scipy\n",
59+
"!{sys.executable} -m pip install json"
60+
]
61+
}
62+
],
63+
"metadata": {
64+
"kernelspec": {
65+
"display_name": "base",
66+
"language": "python",
67+
"name": "python3"
68+
},
69+
"language_info": {
70+
"codemirror_mode": {
71+
"name": "ipython",
72+
"version": 3
73+
},
74+
"file_extension": ".py",
75+
"mimetype": "text/x-python",
76+
"name": "python",
77+
"nbconvert_exporter": "python",
78+
"pygments_lexer": "ipython3",
79+
"version": "3.11.7"
80+
}
81+
},
82+
"nbformat": 4,
83+
"nbformat_minor": 2
8284
}
83-
},
84-
"nbformat": 4,
85-
"nbformat_minor": 2
86-
}

‎Week_1_data_structures/lec_act_1_data_structures.ipynb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"metadata": {
77
"deletable": false,
88
"editable": false
@@ -657,7 +657,7 @@
657657
"name": "python",
658658
"nbconvert_exporter": "python",
659659
"pygments_lexer": "ipython3",
660-
"version": "3.11.7"
660+
"version": "3.12.7"
661661
},
662662
"otter": {
663663
"OK_FORMAT": true,

0 commit comments

Comments
 (0)