diff --git a/lessons/Part1/00_workshop_setup.ipynb b/00_workshop_setup.ipynb similarity index 100% rename from lessons/Part1/00_workshop_setup.ipynb rename to 00_workshop_setup.ipynb diff --git a/lessons/Part1/01_introduction.ipynb b/lessons/Part1/01_introduction.ipynb index 6a5df28..a03bad5 100644 --- a/lessons/Part1/01_introduction.ipynb +++ b/lessons/Part1/01_introduction.ipynb @@ -33,7 +33,7 @@ "\n", "## Coding Strategies\n", "\n", - "Planning ahead can help mitigate time spent dealing with bugs and errors in code. General steps for defensive coding are:\n", + "Planning ahead can help mitigate time spent dealing with bugs and errors in code. General steps for resilient coding are:\n", "\n", "1. State the goals of your code as clearly as possible.\n", "2. Plan out the general logic of steps needed to achieve the goal.\n", @@ -75,13 +75,6 @@ "\n", "Don't reinvent the wheel - learning how to find the answer to the issues you run into is a critical part of becoming a capable programmer!" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/lessons/Part1/02_jupyter_notebooks.ipynb b/lessons/Part1/02_jupyter_notebooks.ipynb index f8f0e89..bd1c6ff 100644 --- a/lessons/Part1/02_jupyter_notebooks.ipynb +++ b/lessons/Part1/02_jupyter_notebooks.ipynb @@ -20,7 +20,7 @@ "source": [ "## Navigating Jupyter Notebooks\n", "\n", - "In Jupyter Notebooks, code is divided into cells which can each be run separately. This is the main distinction between Jupyter Notebook `.ipynb` format and Python script `.py` format. Running a cell is done with a key combination: `Shift+Enter`. `Shift+Enter` will run the code in the selecte cell and then automatically move to the following cell.\n", + "In Jupyter Notebooks, code is divided into cells which can each be run separately. This is the main distinction between Jupyter Notebook `.ipynb` format and Python script `.py` format. Running a cell is done with a key combination: `Shift+Enter`. `Shift+Enter` will run the code in the selected cell and then automatically move to the following cell.\n", "\n", "Try to run the following code using `Shift+Enter` now. \n", "\n", @@ -29,17 +29,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello World!\n" - ] - } - ], + "outputs": [], "source": [ "print(\"Hello World!\")" ] @@ -57,17 +49,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], + "outputs": [], "source": [ "a = 1 + 2\n", "print(a)" @@ -132,17 +116,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "And three shall be the count.\n" - ] - } - ], + "outputs": [], "source": [ "mystring = \"And three shall be the count.\" \n", "\n", @@ -158,17 +134,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "And three shall be the count.\n" - ] - } - ], + "outputs": [], "source": [ "print(mystring)" ] @@ -215,31 +183,6 @@ "outputs": [], "source": [] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Commenting\n", - "\n", - "We will discuss how and why to comment code later in this series, but we will introduce it now because it's useful when you temporarily don't want to run a section of code.\n", - "\n", - "Simply place a pound sign `#` at the beginning of the line, and that line won't run. Any uncommented lines will be treated as code.\n", - "\n", - "Try running the cell below, then comment out `bad_thing`, and run it again. What changes?\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "good_thing = 1+1\n", - "\n", - "This line should be commented\n", - "bad_thing_1 = 'a' * 'b'" - ] - }, { "cell_type": "markdown", "metadata": {}, diff --git a/lessons/Part1/03_variables.ipynb b/lessons/Part1/03_variables.ipynb index 1992df5..123f070 100644 --- a/lessons/Part1/03_variables.ipynb +++ b/lessons/Part1/03_variables.ipynb @@ -57,22 +57,6 @@ "print(\"Year:\", year, \".Month:\", month)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In addition, the argument `sep` (short for separator) can be used to control what goes in between each item." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Year:\", year, \". Month:\", month, sep = '')" - ] - }, { "cell_type": "markdown", "metadata": { @@ -83,8 +67,7 @@ "\n", "* Variable names **must** follow a few rules:\n", " * They cannot start with a digit.\n", - " * They cannot contain spaces, quotation marks, or other punctuation.\n", - " * They *may* contain an underscore (typically used to separate words in long variable names).\n", + " * They cannot contain spaces, quotation marks, or other punctuation (except underscore).\n", " \n", "Not following these rules will result in an error in Python. \n", "\n", @@ -178,7 +161,7 @@ "source": [ "## Challenge 2: Words to Code\n", "\n", - "Translate the following line into code and save the result to a variable. \n", + "Translate the following line into code and save the result to a variable. Start by writing out each operation as a separate step, *then* translate it to code.\n", "\n", "Divide 15 by the sum of a and three times b. Multiply the result by 2 and raise it to the 3rd power. What is the result?\n", "\n", @@ -251,13 +234,6 @@ "source": [ "This is a common technique that is used for swapping variables around. However, often we might choose to just use new variables, rather than overwrite the ones here. Can you think of a reason why we might avoid overwriting a variable?" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/lessons/Part1/04_data_types.ipynb b/lessons/Part1/04_data_types.ipynb index 42a0368..3f8f293 100644 --- a/lessons/Part1/04_data_types.ipynb +++ b/lessons/Part1/04_data_types.ipynb @@ -24,24 +24,17 @@ "* We use the `type()` **function** to identify what the type is of a current variable. Functions are signified by parentheses following them, which contain any inputs to the function.\n", "\n", "\n", - "Let's check the types of some variables below. Predict the type for each variable. Were you surprised by any of the answers?" + "Let's check the types of some variables below. \n", + "\n", + "\n", + "**Question:** Predict the type for each variable. Were you surprised by any of the answers?" ] }, { "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - "\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "pi = 3.14159\n", "print(type(pi))\n", @@ -80,30 +73,11 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1.1415899999999999\n" - ] - }, - { - "ename": "TypeError", - "evalue": "unsupported operand type(s) for -: 'str' and 'str'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [2]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(pi \u001b[38;5;241m-\u001b[39m \u001b[38;5;241m2.0\u001b[39m)\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# Subtraction with strings\u001b[39;00m\n\u001b[1;32m----> 5\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mfitness\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43ma\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m)\n", - "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'str' and 'str'" - ] - } - ], + "outputs": [], "source": [ "# Subtraction with floats\n", "print(pi - 2.0)\n", @@ -121,18 +95,9 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5.14159\n", - "averagea\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "# Addition with floats\n", "print(pi + 2.0)\n", @@ -157,23 +122,11 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "scrolled": true }, - "outputs": [ - { - "ename": "TypeError", - "evalue": "unsupported operand type(s) for -: 'int' and 'str'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [4]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m3\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m 2\u001b[0m b \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m3\u001b[39m\n\u001b[1;32m----> 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mb\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[43m \u001b[49m\u001b[43ma\u001b[49m)\n", - "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'int' and 'str'" - ] - } - ], + "outputs": [], "source": [ "a = '3'\n", "b = 3\n", @@ -190,20 +143,11 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "print(type(b))\n", "print(type(a))" @@ -220,27 +164,9 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - }, - { - "data": { - "text/plain": [ - "int" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(int(a))\n", "type(int(a))" @@ -248,17 +174,9 @@ }, { "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(b - int(a))" ] @@ -272,21 +190,9 @@ }, { "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "ename": "ValueError", - "evalue": "invalid literal for int() with base 10: 'letters'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [9]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mletters\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n", - "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'letters'" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "int('letters')" ] @@ -309,18 +215,9 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Half is 0.5\n", - "Three squared is 9.0\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print('Half is', 1 / 2.0)\n", "print('Three squared is', 3.0 ** 2)" @@ -346,7 +243,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -370,7 +267,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -379,20 +276,9 @@ }, { "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'GIRAFFE'" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "giraffe = 'giraffe'\n", "giraffe.upper()" @@ -407,20 +293,9 @@ }, { "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "'giraffe'.startswith('gir')" ] @@ -436,20 +311,9 @@ }, { "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "False" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "'giraffe'.upper().startswith('gir')" ] @@ -477,7 +341,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -489,7 +353,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -509,7 +373,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ diff --git a/lessons/Part1/05_functions.ipynb b/lessons/Part1/05_functions.ipynb index 74530a6..c6494be 100644 --- a/lessons/Part1/05_functions.ipynb +++ b/lessons/Part1/05_functions.ipynb @@ -34,29 +34,11 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "one two\n" - ] - }, - { - "data": { - "text/plain": [ - "3.142" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "len('before')\n", "print('one', 'two')\n", @@ -69,47 +51,23 @@ "source": [ "A function without the proper number of arguments will give an error, which will give some information about what arguments you need for the function to be successful.\n", "\n", - "**Question:** Look at the errors below. From the error message, how many arguments does the function take?" + "**Question:** The following lines will give errors. From the error message, how many arguments does the function take?" ] }, { "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "len() takes exactly one argument (0 given)", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [9]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "\u001b[1;31mTypeError\u001b[0m: len() takes exactly one argument (0 given)" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "len()" ] }, { "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "round() takes at most 2 arguments (3 given)", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [10]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;43mround\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m3.14\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m)\u001b[49m\n", - "\u001b[1;31mTypeError\u001b[0m: round() takes at most 2 arguments (3 given)" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "round(3.14,1,0)" ] @@ -123,20 +81,9 @@ }, { "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "round" ] @@ -159,17 +106,9 @@ }, { "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(round(3.14))" ] @@ -183,21 +122,9 @@ }, { "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "object of type 'int' has no len()", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [13]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mround\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m3.14\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n", - "\u001b[1;31mTypeError\u001b[0m: object of type 'int' has no len()" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "len(round(3.14))" ] @@ -218,18 +145,9 @@ }, { "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "unexpected EOF while parsing (3071631582.py, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[1;36m Input \u001b[1;32mIn [16]\u001b[1;36m\u001b[0m\n\u001b[1;33m print(max(len('hi', len('hello'))\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m unexpected EOF while parsing\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(max(len('hi', len('hello'))" ] @@ -280,20 +198,9 @@ }, { "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "4" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "round(3.712)" ] @@ -307,20 +214,9 @@ }, { "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "3.7" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "round(3.712, 1)" ] @@ -334,7 +230,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -350,20 +246,9 @@ }, { "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "3.0" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "#this works\n", "round(3.000, 2)" @@ -378,21 +263,9 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "'float' object cannot be interpreted as an integer", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [24]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m#this doesn't\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;43mround\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m3.000\u001b[39;49m\u001b[43m)\u001b[49m\n", - "\u001b[1;31mTypeError\u001b[0m: 'float' object cannot be interpreted as an integer" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "#this doesn't\n", "round(2, 3.000)" @@ -422,20 +295,9 @@ }, { "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(0, 5)" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "divmod(5, 16)" ] @@ -451,24 +313,9 @@ }, { "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Help on built-in function round in module builtins:\n", - "\n", - "round(number, ndigits=None)\n", - " Round a number to a given precision in decimal digits.\n", - " \n", - " The return value is an integer if ndigits is omitted or None. Otherwise\n", - " the return value has the same type as the number. ndigits may be negative.\n", - "\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "help(round)" ] @@ -487,17 +334,9 @@ }, { "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The output of divmod(16, 5) is (3, 1)\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "output = divmod(16, 5)\n", "print('The output of divmod(16, 5) is', output)" @@ -538,18 +377,9 @@ }, { "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "tin\n", - "4\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "rich = \"gold\"\n", "poor = \"tin\"\n", diff --git a/lessons/Part2/07_dictionaries_and_dataframes.ipynb b/lessons/Part2/07_dictionaries_and_dataframes.ipynb index a7ef296..fef7525 100644 --- a/lessons/Part2/07_dictionaries_and_dataframes.ipynb +++ b/lessons/Part2/07_dictionaries_and_dataframes.ipynb @@ -30,20 +30,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1935" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "example_dict = {\n", " \"name\": \"Forough Farrokhzad\",\n", @@ -64,27 +53,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dict_keys(['name', 'year of birth', 'year of death', 'place of birth', 'language'])\n" - ] - }, - { - "data": { - "text/plain": [ - "dict_keys" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "print(example_dict.keys())\n", "type(example_dict.keys())" @@ -99,20 +70,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['name', 'year of birth', 'year of death', 'place of birth', 'language']" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "list(example_dict.keys())" ] @@ -128,7 +88,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -168,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -191,91 +151,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
fruitsizecolor
0apple3red
1orange2orange
2mango3orange
3strawberry1red
4salmonberry1orange
5thimbleberry1red
\n", - "
" - ], - "text/plain": [ - " fruit size color\n", - "0 apple 3 red\n", - "1 orange 2 orange\n", - "2 mango 3 orange\n", - "3 strawberry 1 red\n", - "4 salmonberry 1 orange\n", - "5 thimbleberry 1 red" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "import pandas as pd\n", "\n", @@ -296,20 +174,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(6, 3)" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "df.shape" ] @@ -325,25 +192,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "ValueError", - "evalue": "All arrays must be of the same length", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", - "Input \u001b[1;32mIn [10]\u001b[0m, in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m color \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mred\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124morange\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124myellow\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m 5\u001b[0m fruit_dict \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m 6\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfruit\u001b[39m\u001b[38;5;124m'\u001b[39m: fruit,\n\u001b[0;32m 7\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlength\u001b[39m\u001b[38;5;124m'\u001b[39m: length,\n\u001b[0;32m 8\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcolor\u001b[39m\u001b[38;5;124m'\u001b[39m: color}\n\u001b[1;32m---> 10\u001b[0m df_fruit \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mDataFrame\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfruit_dict\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[1;32m~\\anaconda32022\\lib\\site-packages\\pandas\\core\\frame.py:636\u001b[0m, in \u001b[0;36mDataFrame.__init__\u001b[1;34m(self, data, index, columns, dtype, copy)\u001b[0m\n\u001b[0;32m 630\u001b[0m mgr \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_init_mgr(\n\u001b[0;32m 631\u001b[0m data, axes\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mindex\u001b[39m\u001b[38;5;124m\"\u001b[39m: index, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcolumns\u001b[39m\u001b[38;5;124m\"\u001b[39m: columns}, dtype\u001b[38;5;241m=\u001b[39mdtype, copy\u001b[38;5;241m=\u001b[39mcopy\n\u001b[0;32m 632\u001b[0m )\n\u001b[0;32m 634\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(data, \u001b[38;5;28mdict\u001b[39m):\n\u001b[0;32m 635\u001b[0m \u001b[38;5;66;03m# GH#38939 de facto copy defaults to False only in non-dict cases\u001b[39;00m\n\u001b[1;32m--> 636\u001b[0m mgr \u001b[38;5;241m=\u001b[39m \u001b[43mdict_to_mgr\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindex\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcolumns\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdtype\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcopy\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcopy\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtyp\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmanager\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 637\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(data, ma\u001b[38;5;241m.\u001b[39mMaskedArray):\n\u001b[0;32m 638\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mma\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmrecords\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mmrecords\u001b[39;00m\n", - "File \u001b[1;32m~\\anaconda32022\\lib\\site-packages\\pandas\\core\\internals\\construction.py:502\u001b[0m, in \u001b[0;36mdict_to_mgr\u001b[1;34m(data, index, columns, dtype, typ, copy)\u001b[0m\n\u001b[0;32m 494\u001b[0m arrays \u001b[38;5;241m=\u001b[39m [\n\u001b[0;32m 495\u001b[0m x\n\u001b[0;32m 496\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mhasattr\u001b[39m(x, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdtype\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(x\u001b[38;5;241m.\u001b[39mdtype, ExtensionDtype)\n\u001b[0;32m 497\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m x\u001b[38;5;241m.\u001b[39mcopy()\n\u001b[0;32m 498\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m arrays\n\u001b[0;32m 499\u001b[0m ]\n\u001b[0;32m 500\u001b[0m \u001b[38;5;66;03m# TODO: can we get rid of the dt64tz special case above?\u001b[39;00m\n\u001b[1;32m--> 502\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43marrays_to_mgr\u001b[49m\u001b[43m(\u001b[49m\u001b[43marrays\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcolumns\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindex\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdtype\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtyp\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtyp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mconsolidate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcopy\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[1;32m~\\anaconda32022\\lib\\site-packages\\pandas\\core\\internals\\construction.py:120\u001b[0m, in \u001b[0;36marrays_to_mgr\u001b[1;34m(arrays, columns, index, dtype, verify_integrity, typ, consolidate)\u001b[0m\n\u001b[0;32m 117\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m verify_integrity:\n\u001b[0;32m 118\u001b[0m \u001b[38;5;66;03m# figure out the index, if necessary\u001b[39;00m\n\u001b[0;32m 119\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m index \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m--> 120\u001b[0m index \u001b[38;5;241m=\u001b[39m \u001b[43m_extract_index\u001b[49m\u001b[43m(\u001b[49m\u001b[43marrays\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 121\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 122\u001b[0m index \u001b[38;5;241m=\u001b[39m ensure_index(index)\n", - "File \u001b[1;32m~\\anaconda32022\\lib\\site-packages\\pandas\\core\\internals\\construction.py:674\u001b[0m, in \u001b[0;36m_extract_index\u001b[1;34m(data)\u001b[0m\n\u001b[0;32m 672\u001b[0m lengths \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mset\u001b[39m(raw_lengths))\n\u001b[0;32m 673\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(lengths) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m--> 674\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAll arrays must be of the same length\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 676\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m have_dicts:\n\u001b[0;32m 677\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m 678\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMixing dicts with non-Series may lead to ambiguous ordering.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 679\u001b[0m )\n", - "\u001b[1;31mValueError\u001b[0m: All arrays must be of the same length" - ] - } - ], + "outputs": [], "source": [ "fruit = ['apple', 'orange']\n", "length = [3.2, 2.1, 3.1]\n", @@ -373,28 +224,11 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": { "scrolled": false }, - "outputs": [ - { - "data": { - "text/plain": [ - "0 apple\n", - "1 orange\n", - "2 mango\n", - "3 strawberry\n", - "4 salmonberry\n", - "5 thimbleberry\n", - "Name: fruit, dtype: object" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Bracket notation to choose a column\n", "df['fruit']" @@ -409,18 +243,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n", - "['red' 'orange']\n" - ] - } - ], + "outputs": [], "source": [ "#number of unique colors in the df\n", "print(df['color'].nunique())\n", diff --git a/lessons/Part2/08_loops.ipynb b/lessons/Part2/08_loops.ipynb index 30db703..742621a 100644 --- a/lessons/Part2/08_loops.ipynb +++ b/lessons/Part2/08_loops.ipynb @@ -95,7 +95,7 @@ "outputs": [], "source": [ "# We use a variable containing a list with the values to be iterated through\n", - "tires = [41,35,28]\n", + "tires = [40.9, 35.2, 28.4]\n", "\n", "for pressure in tires:\n", " print(round(pressure))\n", @@ -216,7 +216,7 @@ " 'elevation': [14505, 14379, 14252, 14248, 14179, 13992]}\n", ")\n", "\n", - "mountain_df" + "mountains_df" ] }, { @@ -296,8 +296,8 @@ "total = 0\n", "words = [\"red\", \"green\", \"blue\"]\n", "\n", - "for word in words:\n", - " ____ = ____ + len(word)\n", + "for w in words:\n", + " ____ = ____ + len(w)\n", "\n", "print(total)" ] @@ -318,7 +318,7 @@ "lengths = ____\n", "words = [\"red\", \"green\", \"blue\"]\n", "\n", - "for word in words:\n", + "for w in words:\n", " lengths.____(____)\n", "\n", "print(lengths)" @@ -384,9 +384,9 @@ "pets = ['cat', 'dog', 'hamster', 'iguana']\n", "\n", "# Iterate over pets\n", - "for pet in pets:\n", + "for p in pets:\n", " # Iterate over each letter in a pet\n", - " for letter in pet:\n", + " for letter in p:\n", " print(letter)" ] }, diff --git a/lessons/Part2/09_conditionals.ipynb b/lessons/Part2/09_conditionals.ipynb index 3a063b2..6a41801 100644 --- a/lessons/Part2/09_conditionals.ipynb +++ b/lessons/Part2/09_conditionals.ipynb @@ -376,15 +376,15 @@ "source": [ "numbers = [12, 20, 43, 88, 97, 100, 105, 110]\n", "\n", - "for number in numbers:\n", - " if number > 100:\n", - " print(number, 'is greater than 100.')\n", - " elif number > 50:\n", - " print(number, 'is greater than 50.')\n", - " elif number > 25:\n", - " print(number, 'is greater than 25.')\n", + "for n in numbers:\n", + " if n > 100:\n", + " print(n, 'is greater than 100.')\n", + " elif n > 50:\n", + " print(n, 'is greater than 50.')\n", + " elif n > 25:\n", + " print(n, 'is greater than 25.')\n", " else:\n", - " print(number, 'is less than or equal to 25.')" + " print(n, 'is less than or equal to 25.')" ] }, { @@ -429,23 +429,6 @@ "The order of the if and elif statements matters. When one if/elif statement is met, all following statements are skipped. If there are multiple if statements, then each statement is evaluated separately. These kinds of errors won't give errors in the code, but they will give results that might not make sense, which can take longer to find and debug." ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "original = [-1.5, 0.2, 0.4, 0.0, -1.3, 0.4]\n", - "result = ____\n", - "\n", - "for value in original:\n", - " if ____:\n", - " result.append(0)\n", - " else:\n", - " ____\n", - "print(result)" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -523,13 +506,6 @@ " ____.append(___)\n", "print(last_name_b)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/lessons/Part2/10_custom_functions.ipynb b/lessons/Part2/10_custom_functions.ipynb index 843ab60..8bc3401 100644 --- a/lessons/Part2/10_custom_functions.ipynb +++ b/lessons/Part2/10_custom_functions.ipynb @@ -33,9 +33,9 @@ "\n", "# Accumulate the numbers\n", "total = 0\n", - "for number in numbers:\n", + "for n in numbers:\n", " # Add the current value to the sum of the values\n", - " total = total + number\n", + " total = total + n\n", "print('The sum is', total)\n", "print('Using the sum function:',sum(numbers))" ] @@ -61,9 +61,9 @@ "source": [ "def my_sum(list_of_numbers):\n", " total = 0\n", - " for number in numbers:\n", + " for n in numbers:\n", " # Add the current value to the sum of the values\n", - " total = total + number\n", + " total = total + n\n", " return total" ] }, diff --git a/lessons/Part3/11_libraries.ipynb b/lessons/Part3/11_libraries.ipynb index 549601c..38ee3cd 100644 --- a/lessons/Part3/11_libraries.ipynb +++ b/lessons/Part3/11_libraries.ipynb @@ -25,30 +25,18 @@ "source": [ "## Installing New Libraries\n", "\n", - "### Option 1: Anaconda Navigator\n", "\n", - "Many popular (and some not-so-popular) libraries are available for installation through the Anaconda Navigator. Let's use the Anaconda Navigator to install a library called `fuzzywuzzy`. \n", - "\n", - "To do so, follow these steps:\n", - "\n", - "1. Open the Anaconda Navigator application.\n", - "2. Click the \"Environments\" tab in the left-hand menu.\n", - "3. Click the drop-down box that, by default, says \"Installed\". Change it to say \"All\".\n", - "4. Click the \"Channels\" button, which will open up a dialog box. In that dialog box press the \"Add\" button in the top right corner. Type \"conda-forge\" in the new line that appears in the dialog box, then press enter. Finally, press the green \"Update channels\" button in the bottom right-hand corner.\n", - "5. Use the \"Search Package\" text box to enter `fuzzywuzzy` and press \"Enter\".\n", - "6. Select the checkbox next to the `fuzzywuzzy` package (library) name that appears in the list below.\n", - "7. Click the green \"Apply\" button in the bottom right-hand corner. This will open up a dialog box that says \"Install Packages\". It will say \"Solving package specifications\" with a blue progress bar. This may take a few minutes.\n", - "8. Eventually, it will show a list of packages that would need to be installed. Press the green \"Apply\" button in the \"Install Packages dialog box\" which will install the packages. This may take a few minutes.\n", - "\n", - "### Option 2: Installing Using the Command Line\n", + "### Option 1: Installing Using the Command Line\n", "\n", "Another option is to install a package directly using the command line. On Macs, you would open up the Terminal application. On Windows, open up the Anaconda Prompt application.\n", "\n", - "Once you have this application open, you can use `pip`, a Python package installer, to install new packages from PyPI. Simply run `pip install [PACKAGE_NAME]`, and the package will be installed.\n", + "Once you have this application open, you can use `conda`, a Python package installer, to install new packages from PyPI. Simply run `conda install [PACKAGE_NAME]`, and the package will be installed.\n", + "\n", + "### Option 2: Installing within a Jupyter Notebook\n", "\n", - "### Option 3: Installing within a Jupyter Notebook\n", + "You can also install packages within a Jupyter Notebook. Create a new cell, and run the command `!pip install [PACKAGE_NAME]`. This should then run the `pip` install in the background.\n", "\n", - "You can also install packages within a Jupyter Notebook. Create a new cell, and run the command `!pip install [PACKAGE_NAME]`. This should then run the `pip` install in the background." + "**Note:** If you are on DataHub, Binder, or another cloud-based environment, use Option 2," ] }, { diff --git a/lessons/Part3/12_file_io.ipynb b/lessons/Part3/12_file_io.ipynb index a7240b0..c98a80f 100644 --- a/lessons/Part3/12_file_io.ipynb +++ b/lessons/Part3/12_file_io.ipynb @@ -93,16 +93,7 @@ "\n", "The above example used a relative filepath, since the file is in the same directory. Where was the file in relationship to the current working directory? \n", "\n", - "**Question:** What would the absolute filepath be for your machine? " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# YOUR CODE HERE\n" + "**Note:** The file separator character changes based on your OS. If you have Mac, the character is `'/'`, and if you are on Windows, it is `'\\\\'`. The second backslash is because `\\` alone is used to indicate special characters, for example in `\\t` (tab)." ] }, { @@ -158,7 +149,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "pd.read_csv('/data/capitals2.csv')"