|
55 | 55 | "cell_type": "code", |
56 | 56 | "outputs": [], |
57 | 57 | "execution_count": null, |
58 | | - "source": "# write a print statement here and run it", |
| 58 | + "source": "# write a print statement below and run it\n", |
59 | 59 | "id": "1f40c56b228dc899" |
60 | 60 | }, |
| 61 | + { |
| 62 | + "metadata": {}, |
| 63 | + "cell_type": "markdown", |
| 64 | + "source": "Here's the thing though, when you want to print a number, you need to make sure that you're telling Python how to interpret what you're giving it. Python needs you to tell it what's text, and what's a number. Below are a few different examples. If you put something in quotes, that means it's text. If you put something without quotes, that means you're commanding Python to do something.", |
| 65 | + "id": "7305b807d0f19107" |
| 66 | + }, |
| 67 | + { |
| 68 | + "metadata": {}, |
| 69 | + "cell_type": "code", |
| 70 | + "outputs": [], |
| 71 | + "execution_count": null, |
| 72 | + "source": [ |
| 73 | + "print(2 + 2) # this is a number\n", |
| 74 | + "print(\"2 + 2\") # this is text" |
| 75 | + ], |
| 76 | + "id": "fa6a745b4962d6e3" |
| 77 | + }, |
61 | 78 | { |
62 | 79 | "metadata": {}, |
63 | 80 | "cell_type": "markdown", |
|
69 | 86 | "cell_type": "code", |
70 | 87 | "outputs": [], |
71 | 88 | "execution_count": null, |
72 | | - "source": "# try printing it out here", |
| 89 | + "source": "# try printing it out below\n", |
73 | 90 | "id": "f491bccb1ea66088" |
74 | 91 | }, |
75 | 92 | { |
|
219 | 236 | { |
220 | 237 | "metadata": { |
221 | 238 | "ExecuteTime": { |
222 | | - "end_time": "2025-09-19T16:17:06.845303Z", |
223 | | - "start_time": "2025-09-19T16:17:06.612175Z" |
| 239 | + "end_time": "2025-09-22T17:21:18.199693Z", |
| 240 | + "start_time": "2025-09-22T17:21:18.190563Z" |
224 | 241 | } |
225 | 242 | }, |
226 | 243 | "cell_type": "code", |
|
236 | 253 | "name": "stdout", |
237 | 254 | "output_type": "stream", |
238 | 255 | "text": [ |
239 | | - "5\n" |
240 | | - ] |
241 | | - }, |
242 | | - { |
243 | | - "ename": "TypeError", |
244 | | - "evalue": "can only concatenate str (not \"float\") to str", |
245 | | - "output_type": "error", |
246 | | - "traceback": [ |
247 | | - "\u001B[31m---------------------------------------------------------------------------\u001B[39m", |
248 | | - "\u001B[31mTypeError\u001B[39m Traceback (most recent call last)", |
249 | | - "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[1]\u001B[39m\u001B[32m, line 4\u001B[39m\n\u001B[32m 2\u001B[39m \u001B[38;5;28mprint\u001B[39m(x)\n\u001B[32m 3\u001B[39m pi = \u001B[32m3.1415962\u001B[39m\n\u001B[32m----> \u001B[39m\u001B[32m4\u001B[39m \u001B[38;5;28mprint\u001B[39m(\u001B[33;43m\"\u001B[39;49m\u001B[33;43mI love \u001B[39;49m\u001B[33;43m\"\u001B[39;49m\u001B[43m \u001B[49m\u001B[43m+\u001B[49m\u001B[43m \u001B[49m\u001B[43mpi\u001B[49m)\n", |
250 | | - "\u001B[31mTypeError\u001B[39m: can only concatenate str (not \"float\") to str" |
| 256 | + "5\n", |
| 257 | + "I love 3.1415962\n" |
251 | 258 | ] |
252 | 259 | } |
253 | 260 | ], |
|
321 | 328 | "outputs": [], |
322 | 329 | "execution_count": null, |
323 | 330 | "source": [ |
| 331 | + "# this is a comment and doesn't run\n", |
| 332 | + "# i can leave notes on what my code does\n", |
324 | 333 | "# The following code prints out 2\n", |
325 | 334 | "print (1 + 1)" |
326 | 335 | ], |
|
338 | 347 | ], |
339 | 348 | "id": "b18a664c7e3bdf06" |
340 | 349 | }, |
| 350 | + { |
| 351 | + "metadata": {}, |
| 352 | + "cell_type": "markdown", |
| 353 | + "source": "Try writing a comment to explain what the code below does", |
| 354 | + "id": "b42f5ed82e7a36ff" |
| 355 | + }, |
| 356 | + { |
| 357 | + "metadata": {}, |
| 358 | + "cell_type": "code", |
| 359 | + "outputs": [], |
| 360 | + "execution_count": null, |
| 361 | + "source": [ |
| 362 | + "cheese = 3\n", |
| 363 | + "if cheese * 2 > 3:\n", |
| 364 | + " print(\"that's a lot of cheese!\")" |
| 365 | + ], |
| 366 | + "id": "950d531874ef341a" |
| 367 | + }, |
341 | 368 | { |
342 | 369 | "metadata": {}, |
343 | 370 | "cell_type": "markdown", |
|
0 commit comments