diff --git a/basics/basics_notebook.ipynb b/basics/basics_notebook.ipynb index e1f450b..d83cdf9 100644 --- a/basics/basics_notebook.ipynb +++ b/basics/basics_notebook.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Python Basics at PyCAR2020" + "# Python Basics" ] }, { @@ -26,7 +26,7 @@ "\n", "(Most of us ask questions we've asked before daily — we just ask them of Google.)\n", "\n", - "Now for some code. Let's say you want to search 130,000 lines of text for certain tems -- which are most common, how frequently do they occur, how often are they used in a way that's concentrated, which might indicate places you want to look more closely.\n", + "Now for some code. Let's say you want to search 130,000 lines of text for certain terms -- which are most common, how frequently do they occur, how often are they used in a way that's concentrated, which might indicate places you want to look more closely.\n", "\n", "No person wants to do that by hand. And people are bad at precisely that kind of work. But it's perfect for a computer.\n", "\n", @@ -97,7 +97,7 @@ "source": [ "So any time we want to check to see how many times we've seen our `search_term` or check where our `file_location` is, we can use these variables instead of typing out the card value!\n", "\n", - "If you forget what one of the variables is set to, you can print your string. (The ```print()``` command was optional in Python 2.x, but is now required in Python 3.x.) Let's also make a comment to remind us of what this variable does." + "If you forget what one of the variables is set to, you can `print` your string. Let's also make a comment to remind us of what this variable does." ] }, { @@ -375,18 +375,25 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "As you’ve just seen, programming can be pretty tedious when you’re trying to break tasks down. So now that you’ve gotten a little bit of a taste for what writing a program is like, let’s dive into some of [the nitty-gritty basics](basics_reference_completed.ipynb), like how you strip whitespace from a string and what happens when you mix a float and an integer.\n", + "As you’ve just seen, programming can be pretty tedious when you’re trying to break tasks down. So now that you’ve gotten a little bit of a taste for what writing a program is like, let’s dive into some of [the nitty-gritty basics](../completed/basics_reference_completed.ipynb), like how you strip whitespace from a string and what happens when you mix a float and an integer.\n", "\n", "That sounds like a lot of fun. It must. It does. We promise.\n", "\n", "Onward." ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -400,9 +407,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.11.6" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 } diff --git a/completed/basics_complete_notebook.ipynb b/completed/basics_complete_notebook.ipynb index 5a7d3a3..09f8e1b 100644 --- a/completed/basics_complete_notebook.ipynb +++ b/completed/basics_complete_notebook.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Python Basics at PyCAR2020" + "# Python Basics" ] }, { @@ -26,7 +26,7 @@ "\n", "(Most of us ask questions we've asked before daily — we just ask them of Google.)\n", "\n", - "Now for some code. Let's say you want to search 130,000 lines of text for certain tems -- which are most common, how frequently do they occur, how often are they used in a way that's concentrated, which might indicate places you want to look more closely.\n", + "Now for some code. Let's say you want to search 130,000 lines of text for certain terms -- which are most common, how frequently do they occur, how often are they used in a way that's concentrated, which might indicate places you want to look more closely.\n", "\n", "No person wants to do that by hand. And people are bad at precisely that kind of work. But it's perfect for a computer.\n", "\n", @@ -52,7 +52,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -69,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -86,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -100,12 +100,12 @@ "source": [ "So any time we want to check to see how many times we've seen our `search_term` or check where our `file_location` is, we can use these variables instead of typing out the card value!\n", "\n", - "If you forget what one of the variables is set to, you can print it out. (The ```print()``` command was optional in Python 2.x, but is now required in Python 3.x.) Let's also make a comment to remind us of what this variable does." + "If you forget what one of the variables is set to, you can `print` it out. Let's also make a comment to remind us of what this variable does." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -122,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -132,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -151,7 +151,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -168,7 +168,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -201,7 +201,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -217,7 +217,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -237,9 +237,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "achilles was in The Iliad 418 times\n" + ] + } + ], "source": [ "# we can do it by adding the strings to one another like this:\n", "print(search_term + ' was in The Iliad ' + str(term_count) + ' times')" @@ -247,9 +255,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "achilles was in The Iliad 418 times\n" + ] + } + ], "source": [ "# or we can use what Python calls `f-strings`, which allow us to drop variables directly into a string;\n", "# doing it this way means we don't have to keep track as much of wayward spaces or\n", @@ -266,9 +282,18 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "It was on the same line multiple times 5 times\n", + "it was on lines [11674, 13351, 16400, 20182, 20640] multiple times\n" + ] + } + ], "source": [ "print(f'It was on the same line multiple times {multi_term_line} {times}')\n", "print(f'it was on lines {line_numbers_list} multiple times')" @@ -290,7 +315,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -307,7 +332,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -323,7 +348,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -340,7 +365,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -357,7 +382,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -374,9 +399,22 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "103\n", + "37\n", + "279\n", + "28\n", + "1\n", + "215\n" + ] + } + ], "source": [ "print(most_common_words[\"homer\"])\n", "print(most_common_words['paris'])\n", @@ -388,7 +426,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -402,9 +440,19 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The most common word in The Iliad is: the\n", + "It is in The Iliad 15447 times\n", + "Wow! How cool is that?\n" + ] + } + ], "source": [ "print(f'The most common word in The Iliad is: {most_common_word}')\n", "print(f'It is in The Iliad {highest_count} times')\n", @@ -415,7 +463,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "As you’ve just seen, programming can be pretty tedious when you’re trying to break tasks down. So now that you’ve gotten a little bit of a taste for what writing a program is like, let’s dive into some of [the nitty-gritty basics](basics_reference_completed.ipynb), like how you strip whitespace from a string and what happens when you mix a float and an integer.\n", + "As you’ve just seen, programming can be pretty tedious when you’re trying to break tasks down. So now that you’ve gotten a little bit of a taste for what writing a program is like, let’s dive into some of [the nitty-gritty basics](../completed/basics_reference_completed.ipynb), like how you strip whitespace from a string and what happens when you mix a float and an integer.\n", "\n", "That sounds like a lot of fun. It must. It does. We promise.\n", "\n", @@ -433,7 +481,7 @@ "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -447,9 +495,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.11.6" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 4 }