|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": 3, |
| 5 | + "execution_count": 1, |
6 | 6 | "metadata": { |
7 | 7 | "deletable": false, |
8 | 8 | "editable": false |
|
36 | 36 | }, |
37 | 37 | { |
38 | 38 | "cell_type": "code", |
39 | | - "execution_count": null, |
| 39 | + "execution_count": 2, |
40 | 40 | "metadata": {}, |
41 | 41 | "outputs": [], |
42 | 42 | "source": [ |
|
72 | 72 | }, |
73 | 73 | { |
74 | 74 | "cell_type": "code", |
75 | | - "execution_count": null, |
| 75 | + "execution_count": 3, |
76 | 76 | "metadata": { |
77 | 77 | "tags": [] |
78 | 78 | }, |
79 | | - "outputs": [], |
| 79 | + "outputs": [ |
| 80 | + { |
| 81 | + "name": "stdout", |
| 82 | + "output_type": "stream", |
| 83 | + "text": [ |
| 84 | + "foo data1.csv\n" |
| 85 | + ] |
| 86 | + } |
| 87 | + ], |
80 | 88 | "source": [ |
81 | 89 | "# TODO: Create a string from the following variables\n", |
82 | 90 | "\n", |
|
86 | 94 | "\n", |
87 | 95 | "\n", |
88 | 96 | "# TODO: replace ... with string creation\n", |
89 | | - "data_file_name = ...\n", |
| 97 | + "data_file_name = \"data1.csv\"\n", |
90 | 98 | "\n", |
91 | 99 | "# This is what the autograder will check\n", |
92 | | - "assert data_file_name == \"data1.csv\"" |
| 100 | + "assert data_file_name == \"data1.csv\"\n", |
| 101 | + "\n", |
| 102 | + "print(f\"foo {data_file_name}\")" |
93 | 103 | ] |
94 | 104 | }, |
95 | 105 | { |
96 | 106 | "cell_type": "code", |
97 | | - "execution_count": null, |
| 107 | + "execution_count": 4, |
98 | 108 | "metadata": { |
99 | 109 | "tags": [] |
100 | 110 | }, |
101 | | - "outputs": [], |
| 111 | + "outputs": [ |
| 112 | + { |
| 113 | + "ename": "AssertionError", |
| 114 | + "evalue": "", |
| 115 | + "output_type": "error", |
| 116 | + "traceback": [ |
| 117 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 118 | + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", |
| 119 | + "Cell \u001b[0;32mIn[4], line 21\u001b[0m\n\u001b[1;32m 18\u001b[0m new_file_name \u001b[38;5;241m=\u001b[39m file_name\n\u001b[1;32m 20\u001b[0m \u001b[38;5;66;03m# This is what the autograder will check\u001b[39;00m\n\u001b[0;32m---> 21\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m new_file_name \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfname1.csv\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", |
| 120 | + "\u001b[0;31mAssertionError\u001b[0m: " |
| 121 | + ] |
| 122 | + } |
| 123 | + ], |
102 | 124 | "source": [ |
103 | 125 | "file_name = \"fname.txt\"\n", |
104 | 126 | "which_one = 1\n", |
|
125 | 147 | }, |
126 | 148 | { |
127 | 149 | "cell_type": "code", |
128 | | - "execution_count": null, |
| 150 | + "execution_count": 9, |
129 | 151 | "metadata": { |
130 | 152 | "deletable": false, |
131 | 153 | "editable": false |
132 | 154 | }, |
133 | | - "outputs": [], |
| 155 | + "outputs": [ |
| 156 | + { |
| 157 | + "data": { |
| 158 | + "text/html": [ |
| 159 | + "<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 passed</pre><p><strong><pre style='display: inline;'>Strings - 2</pre> result:</strong></p><pre> ❌ Test case failed\n", |
| 160 | + " Trying:\n", |
| 161 | + " assert new_file_name == 'fname1.csv'\n", |
| 162 | + " Expecting nothing\n", |
| 163 | + " **********************************************************************\n", |
| 164 | + " Line 1, in Strings 1\n", |
| 165 | + " Failed example:\n", |
| 166 | + " assert new_file_name == 'fname1.csv'\n", |
| 167 | + " Exception raised:\n", |
| 168 | + " Traceback (most recent call last):\n", |
| 169 | + " File \"/opt/anaconda3/lib/python3.12/doctest.py\", line 1368, in __run\n", |
| 170 | + " exec(compile(example.source, filename, \"single\",\n", |
| 171 | + " File \"<doctest Strings 1[0]>\", line 1, in <module>\n", |
| 172 | + " assert new_file_name == 'fname1.csv'\n", |
| 173 | + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", |
| 174 | + " AssertionError\n", |
| 175 | + "</pre>" |
| 176 | + ], |
| 177 | + "text/plain": [ |
| 178 | + "Strings results:\n", |
| 179 | + " Strings - 1 result:\n", |
| 180 | + " ✅ Test case passed\n", |
| 181 | + "\n", |
| 182 | + " Strings - 2 result:\n", |
| 183 | + " ❌ Test case failed\n", |
| 184 | + " Trying:\n", |
| 185 | + " assert new_file_name == 'fname1.csv'\n", |
| 186 | + " Expecting nothing\n", |
| 187 | + " **********************************************************************\n", |
| 188 | + " Line 1, in Strings 1\n", |
| 189 | + " Failed example:\n", |
| 190 | + " assert new_file_name == 'fname1.csv'\n", |
| 191 | + " Exception raised:\n", |
| 192 | + " Traceback (most recent call last):\n", |
| 193 | + " File \"/opt/anaconda3/lib/python3.12/doctest.py\", line 1368, in __run\n", |
| 194 | + " exec(compile(example.source, filename, \"single\",\n", |
| 195 | + " File \"<doctest Strings 1[0]>\", line 1, in <module>\n", |
| 196 | + " assert new_file_name == 'fname1.csv'\n", |
| 197 | + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", |
| 198 | + " AssertionError" |
| 199 | + ] |
| 200 | + }, |
| 201 | + "execution_count": 9, |
| 202 | + "metadata": {}, |
| 203 | + "output_type": "execute_result" |
| 204 | + } |
| 205 | + ], |
134 | 206 | "source": [ |
135 | 207 | "grader.check(\"Strings\")" |
136 | 208 | ] |
|
346 | 418 | "name": "python", |
347 | 419 | "nbconvert_exporter": "python", |
348 | 420 | "pygments_lexer": "ipython3", |
349 | | - "version": "3.11.7" |
| 421 | + "version": "3.12.4" |
350 | 422 | }, |
351 | 423 | "otter": { |
352 | 424 | "OK_FORMAT": true, |
|
0 commit comments