I'm stopped the string. You can use combinations of double and single quotes to get the complete statement."
+ "The reason for the error above is because Python thought that the single quote in I'm marked the end of the string. Instead, you can use a combination of double and single quotes to avoid this kind of problem. "
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "wSVUTR4LNsAK",
- "colab": {}
+ "id": "wSVUTR4LNsAK"
},
"source": [
"\"This shouldn't cause an error now.\""
@@ -792,7 +813,6 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "4I_0dIPHNsAN"
},
"source": [
@@ -802,21 +822,18 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "vfiOvQCHNsAO"
},
"source": [
"### Printing Strings\n",
"\n",
- "Jupyter Notebooks have many neat functions that aren't available in base python. One of those is the ability to print strings by just typing it into a cell. The universal way to display strings however, is to use a **print()** function."
+ "Jupyter Notebooks have many neat features that aren't available in normal Python. One of those is the ability to display strings by just typing it into a cell and running it. The universal Python way to display strings, however, is to use a **print()** statement."
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "pDoK1QbvNsAO",
- "colab": {}
+ "id": "pDoK1QbvNsAO"
},
"source": [
"# In Jupyter, this is all we need\n",
@@ -828,9 +845,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "DArJAbvzNsAV",
- "colab": {}
+ "id": "DArJAbvzNsAV"
},
"source": [
"# But we can't print multiple strings\n",
@@ -843,7 +858,6 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "JzKtMgFeNsAZ"
},
"source": [
@@ -853,34 +867,49 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
"id": "1lSct0DqNsAZ",
- "colab": {}
+ "outputId": "fb480fb4-2ffd-4e0c-9ad5-274173b2ee4e",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 102
+ }
},
"source": [
"print('Hello World')\n",
"print('Second string')\n",
- "print('\\n prints a new line')\n",
+ "\n",
+ "# \"\\n\" prints a new line\n",
"print('\\n')\n",
+ "\n",
"print('Just to prove it to you.')"
],
"execution_count": null,
- "outputs": []
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "Hello World\n",
+ "Second string\n",
+ "\n",
+ "\n",
+ "Just to prove it to you.\n"
+ ],
+ "name": "stdout"
+ }
+ ]
},
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "gENpAoMScPl7"
},
"source": [
- "Now let's move on to understanding how we can manipulate strings in our programs."
+ "Now let's move on to understanding how we can work with strings in our programs."
]
},
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "5IkjMPlcNsAd"
},
"source": [
@@ -890,52 +919,72 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "3Ti5Nv7aNsAe"
},
"source": [
- "Oftentimes, we would like to know how many characters are in a string. We can do this very easily with the **len()** function."
+ "Strings are made up of characters, which are anything you type. \n",
+ "\n",
+ "For example, the following is a string: \"I ate 3 cookies.\" \n",
+ "From this sentence, the \"I\", the \"3\", the spaces \" \", as well as the period \".\" are examples of characters. \n",
+ "\n",
+ "Oftentimes, we would like to know how many characters are in a string. \n",
+ "\n",
+ "We can do this very easily with the **len()** statement. \"len\" is short for length. "
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
"id": "uBNGvj9uNsAf",
- "colab": {}
+ "outputId": "6e350fa2-0e42-4e4f-b603-8c641200fa74",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 34
+ }
},
"source": [
"len('Hello World')"
],
"execution_count": null,
- "outputs": []
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "11"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 7
+ }
+ ]
},
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "bZonsZQnNsAi"
},
"source": [
- "Python's built-in len() function counts all of the characters in the string, including spaces and punctuation."
+ "Python's built-in len() function counts all of the characters in the string, including spaces and punctuation.\n",
+ "\n",
+ "Note: We are utilizing the term \"function\" which will be explained in further detail later on in the course. "
]
},
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "AgTf4FqtcnD9"
},
"source": [
- "Naturally, we can assign strings to variables."
+ "Just as we did with numbers, we can assign strings to variables."
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "RbYyeFrLNsAk",
- "colab": {}
+ "id": "RbYyeFrLNsAk"
},
"source": [
"# Assign 'Hello World' to mystring variable\n",
@@ -947,9 +996,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "3sAvAFHzNsAp",
- "colab": {}
+ "id": "3sAvAFHzNsAp"
},
"source": [
"# Did it work?\n",
@@ -961,9 +1008,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "Dda7HfhGNsAr",
- "colab": {}
+ "id": "Dda7HfhGNsAr"
},
"source": [
"# Print it to make sure\n",
@@ -975,22 +1020,25 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "lk8bxjtCNsAw"
},
"source": [
- "As stated before, Python treats strings as a sequence of characters. That means we can interact with each letter in a string and manipulate it. The way we access these letters is called **indexing**. Each letter has an index, which corresponds to their position in the string. In python, indices start at 0. For instance, in the string 'Hello World', 'H' has an index of 0, the 'W' has an index of 6 (because spaces count as characters), and 'd' has an index of 10. The syntax for indexing is shown below."
+ "As stated before, Python treats strings as a set of characters. That means we can interact with each individual letter in a string and work with it. \n",
+ "\n",
+ "The way we pick out these letters is called **indexing**. \n",
+ "\n",
+ "Imagine a line of people. Then there is a first person in line, a second, and so forth. As you are referring to these individuals by their position in line, you are indexing. You can apply this same concept to strings! \n",
+ "\n",
+ "Each letter has an index, which corresponds to their position within the string. In Python, indices start at 0. For instance, in the string 'Hello World', 'H' has an index of 0, the 'W' has an index of 6 (because spaces also count as characters), and 'd' has an index of 10. The format for indexing is shown below."
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "Fgzo1XrCNsAx",
- "colab": {}
+ "id": "Fgzo1XrCNsAx"
},
"source": [
- "# Extract first character in a string.\n",
+ "# Index first character in a string.\n",
"mystring[0]"
],
"execution_count": null,
@@ -999,9 +1047,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "0kcd-9EZNsA1",
- "colab": {}
+ "id": "0kcd-9EZNsA1"
},
"source": [
"mystring[1]"
@@ -1012,9 +1058,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "8M44L4hMNsA4",
- "colab": {}
+ "id": "8M44L4hMNsA4"
},
"source": [
"mystring[2]"
@@ -1025,22 +1069,19 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "ky7Zm-NENsA7"
},
"source": [
- "We can use a : to perform *slicing* which grabs everything up to a designated index. For example:"
+ "We can use a : to perform *slicing* which allows you to pick out multiple characters in a string at once. To do so, you specify a range of indices. For example:"
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "jQKnWrNtNsA8",
- "colab": {}
+ "id": "jQKnWrNtNsA8"
},
"source": [
- "# Grab all letters past the first letter all the way to the end of the string\n",
+ "# Grab all letters past the first letter all the way to the end of the string. This is a trivial example. \n",
"mystring[:]"
],
"execution_count": null,
@@ -1049,9 +1090,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "otKc90t_NsBB",
- "colab": {}
+ "id": "otKc90t_NsBB"
},
"source": [
"# This does not change the original string in any way\n",
@@ -1063,57 +1102,91 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
"id": "f9xrirSANsBD",
- "colab": {}
+ "outputId": "86717c0a-a18e-443f-9227-3f4aabd47cb4",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
},
"source": [
"# Grab everything UP TO the 5th index\n",
"mystring[:5]"
],
"execution_count": null,
- "outputs": []
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'Hello'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 10
+ }
+ ]
},
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "5dp4GDO0NsBG"
},
"source": [
- "Note what happened above. We told Python to grab everything from 0 up to 5. It doesn't include the character in the 5th index. You'll notice this a lot in Python, where statements are usually in the context of \"up to, but not including\"."
+ "Note what happened above. We told Python to grab everything from 0 up to 5. It doesn't include the character in the 5th index (\" \"). You'll notice this a lot in Python, where statements are usually in the context of \"up to, but not including\"."
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "WfpDNfiKNsBG",
- "colab": {}
+ "id": "mfUzDlat-WqH",
+ "outputId": "81b3ecd9-d8b2-4295-8d76-bf74cb29bcb2",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
},
"source": [
- "# The whole string\n",
- "mystring[:]"
+ "# Grab everything from \"1\" to before \"o\"\n",
+ "mystring[2:7]"
],
"execution_count": null,
- "outputs": []
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'llo W'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 9
+ }
+ ]
},
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "lksAiQL6NsBK"
},
"source": [
- "We don't have to go forwards. Negative indexing allows us to start from the *end* of the string and work backwards."
+ "We don't always have to index from the beginning to the end. Negative indexing allows us to start from the *end* of the string and work backwards."
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "8TywqyZ-NsBL",
- "colab": {}
+ "id": "8TywqyZ-NsBL"
},
"source": [
"# Last letter (one index behind 0 so it loops back around)\n",
@@ -1125,9 +1198,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "LTzPovveNsBO",
- "colab": {}
+ "id": "LTzPovveNsBO"
},
"source": [
"# Grab everything but the last letter\n",
@@ -1139,22 +1210,19 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "XxBxY0SBNsBQ"
},
"source": [
- "We can also use indexing and slicing to grab characters by a specified step size (1 is the default). See the following examples."
+ "We can also use indexing and slicing to skip characters by a specified amount (1 is the default step size which means we do not skip any characters). See the following examples:"
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "D4GZPT3mNsBR",
- "colab": {}
+ "id": "D4GZPT3mNsBR"
},
"source": [
- "# Grab everything, but go in steps size of 1\n",
+ "# Grab everything, but go in step size of 1\n",
"mystring[::1]"
],
"execution_count": null,
@@ -1163,12 +1231,10 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "PjDfDe3gNsBU",
- "colab": {}
+ "id": "PjDfDe3gNsBU"
},
"source": [
- "# Grab everything, but go in step sizes of 2\n",
+ "# Grab everything, but go in step size of 2\n",
"mystring[0::2]"
],
"execution_count": null,
@@ -1177,9 +1243,7 @@
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
- "id": "5t-mgi-KNsBW",
- "colab": {}
+ "id": "5t-mgi-KNsBW"
},
"source": [
"# A handy way to reverse a string!\n",
@@ -1191,69 +1255,98 @@
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "jPCEC_LvfRZp"
},
"source": [
- "Strings have certain properties to them that affect the way we can, and cannot, interact with them."
+ "Strings have certain properties to them that affect the way we can, and cannot, work with them."
]
},
{
"cell_type": "markdown",
"metadata": {
- "colab_type": "text",
"id": "P1U1VtJENsBZ"
},
"source": [
"### String Properties\n",
- "It's important to note that strings are *immutable*. This means that once a string is created, the elements within it can not be changed or replaced. For example:"
+ "It's important to note that strings are *immutable*. This means that once a string is created, the characters within it can not be changed or replaced. For example:"
]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
"id": "xvPyEmYpNsBa",
- "colab": {}
+ "outputId": "9c133349-303b-4593-de9c-1b6dc11dd50f",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ }
},
"source": [
"mystring"
],
"execution_count": null,
- "outputs": []
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ },
+ "text/plain": [
+ "'Hello World'"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 4
+ }
+ ]
},
{
"cell_type": "code",
"metadata": {
- "colab_type": "code",
"id": "NDk66bjZNsBc",
- "colab": {}
+ "outputId": "13f2c1c8-c6c1-43a3-a4fa-12e48d73bcb5",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 181
+ }
},
"source": [
"# Let's try to change the first letter\n",
"mystring[0] = 'a'"
],
"execution_count": null,
- "outputs": []
+ "outputs": [
+ {
+ "output_type": "error",
+ "ename": "TypeError",
+ "evalue": "ignored",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
+ "\u001b[0;32mIn the table below, a=9 and b=11.
\n", "\n", @@ -3265,7 +3256,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "Oxyatrdj28ow" }, "source": [ @@ -3277,9 +3267,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "rPThJGsl28ox", - "colab": {} + "id": "rPThJGsl28ox" }, "source": [ "4 == 4" @@ -3290,9 +3278,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "W2W27aBp28o1", - "colab": {} + "id": "W2W27aBp28o1" }, "source": [ "1 == 0" @@ -3303,7 +3289,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "gtzQpCPO28o5" }, "source": [ @@ -3313,7 +3298,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "4FSgFc8y28o5" }, "source": [ @@ -3323,9 +3307,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "BNQaWArv28o6", - "colab": {} + "id": "BNQaWArv28o6" }, "source": [ "4 != 5" @@ -3336,9 +3318,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "D9hVgJsD28o9", - "colab": {} + "id": "D9hVgJsD28o9" }, "source": [ "1 != 1" @@ -3349,7 +3329,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "iVvotha-28pD" }, "source": [ @@ -3359,9 +3338,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "qA1VVR7128pI", - "colab": {} + "id": "qA1VVR7128pI" }, "source": [ "8 > 3" @@ -3372,9 +3349,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "PrZb9Zy_28pN", - "colab": {} + "id": "PrZb9Zy_28pN" }, "source": [ "1 > 9" @@ -3385,7 +3360,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "PYK9vEa-28pT" }, "source": [ @@ -3395,9 +3369,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "f5x67fWk28pU", - "colab": {} + "id": "f5x67fWk28pU" }, "source": [ "3 < 8" @@ -3408,9 +3380,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "1eB15ns928pX", - "colab": {} + "id": "1eB15ns928pX" }, "source": [ "7 < 0" @@ -3421,7 +3391,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "wDXSDbik28pa" }, "source": [ @@ -3431,9 +3400,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "k4BQs2oB28pb", - "colab": {} + "id": "k4BQs2oB28pb" }, "source": [ "7 >= 7" @@ -3444,9 +3411,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "BPBKLDtb28pd", - "colab": {} + "id": "BPBKLDtb28pd" }, "source": [ "9 >= 4" @@ -3457,7 +3422,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "ai1kLMhy28pi" }, "source": [ @@ -3467,9 +3431,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "5KuB4wd028pi", - "colab": {} + "id": "5KuB4wd028pi" }, "source": [ "4 <= 4" @@ -3480,9 +3442,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "YFbO6yih28pl", - "colab": {} + "id": "YFbO6yih28pl" }, "source": [ "1 <= 3" @@ -3493,17 +3453,15 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "eIDePOLk28po" }, "source": [ - "Hopefully this was more of a review than anything new! Next, we move on to one of the most important aspects of building programs: functions and how to use them." + "Hopefully this was more of a review than anything new! Next, we move on to one of the most important aspects of building programs: functions." ] }, { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "JWmMpmPaNWcX" }, "source": [ @@ -3511,13 +3469,13 @@ "\n", "### Introduction to Functions\n", "\n", - "Here, we will explain what a function is in Python and how to create one. Functions will be one of our main building blocks when we construct larger and larger amounts of code to solve problems.\n", + "In data science, you will come across issue where you would have to run a piece of code again and again inputting a different variable for every one run. This can get exhaustaing and is also very inefficient. Luckily, programming tools have something known as functions. \n", "\n", "**So what is a function?**\n", "\n", - "Formally, a function is a useful device that groups together a set of statements so they can be run more than once. They can also let us specify parameters that can serve as inputs to the functions.\n", + "A function allows you to re run the same piece of code multiple times without manually having to change every line. \n", "\n", - "On a more fundamental level, functions allow us to not have to repeatedly write the same code again and again. If you remember back to the lessons on strings and lists, remember that we used a function len() to get the length of a string. Since checking the length of a sequence is a common task you would want to write a function that can do this repeatedly at command.\n", + "On a more fundamental level, functions allow us to not have to repeatedly write the same code again and again. If you remember back to the lessons on strings and lists, remember that we used a function len() to get the length of a string. Since checking the length of a sequence is a common task, you would want to write a function that can do this repeatedly at command.\n", "\n", "Functions will be one of most basic levels of reusing code in Python, and it will also allow us to start thinking of program design." ] @@ -3525,7 +3483,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "-ghJ1ZQJNWcZ" }, "source": [ @@ -3537,9 +3494,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "b6z3S5eaNWca", - "colab": {} + "id": "b6z3S5eaNWca" }, "source": [ "def name_of_function(arg1,arg2):\n", @@ -3555,7 +3510,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "fUoJtJgHNWcf" }, "source": [ @@ -3575,7 +3529,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "bybS0BdINWcf" }, "source": [ @@ -3585,9 +3538,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "QXDcJHwcNWcg", - "colab": {} + "id": "QXDcJHwcNWcg" }, "source": [ "def say_hello():\n", @@ -3599,7 +3550,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "CfOFuqNENWcj" }, "source": [ @@ -3609,9 +3559,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "yP0KFROlNWck", - "colab": {} + "id": "yP0KFROlNWck" }, "source": [ "say_hello()" @@ -3622,7 +3570,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "HK25wgkKNWcn" }, "source": [ @@ -3633,9 +3580,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "THien-GyNWcp", - "colab": {} + "id": "THien-GyNWcp" }, "source": [ "def greeting(name):\n", @@ -3647,9 +3592,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "-P1sYGzENWcu", - "colab": {} + "id": "-P1sYGzENWcu" }, "source": [ "greeting('Bob')" @@ -3660,7 +3603,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "6im_y8_9NWcx" }, "source": [ @@ -3673,9 +3615,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "o3Lmm8SgNWcy", - "colab": {} + "id": "o3Lmm8SgNWcy" }, "source": [ "def add_num(num1,num2):\n", @@ -3687,9 +3627,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "rl_WvYjkNWc1", - "colab": {} + "id": "rl_WvYjkNWc1" }, "source": [ "add_num(4,5)" @@ -3700,9 +3638,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "VuEvJPq1NWc5", - "colab": {} + "id": "VuEvJPq1NWc5" }, "source": [ "# Can also save as variable due to return\n", @@ -3714,9 +3650,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "f0ad5-kaNWc8", - "colab": {} + "id": "f0ad5-kaNWc8" }, "source": [ "print(result)" @@ -3727,7 +3661,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "15lkNnVPNWc_" }, "source": [ @@ -3737,9 +3670,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "1hlftLo7NWc_", - "colab": {} + "id": "1hlftLo7NWc_" }, "source": [ "add_num('one','two')" @@ -3750,7 +3681,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "eBJTPKYjNWdD" }, "source": [ @@ -3762,7 +3692,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "FQQ7-olXNWdD" }, "source": [ @@ -3774,9 +3703,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "o82eSDSaNWdE", - "colab": {} + "id": "o82eSDSaNWdE" }, "source": [ "def is_prime(num):\n", @@ -3796,9 +3723,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "68obU1f7NWdH", - "colab": {} + "id": "68obU1f7NWdH" }, "source": [ "is_prime(16)" @@ -3809,9 +3734,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "uqlUE7j2NWdK", - "colab": {} + "id": "uqlUE7j2NWdK" }, "source": [ "is_prime(17)" @@ -3822,7 +3745,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "rPO1ypnINWdN" }, "source": [ @@ -3836,9 +3758,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "1sMwpbK0NWdO", - "colab": {} + "id": "1sMwpbK0NWdO" }, "source": [ "import math\n", @@ -3860,9 +3780,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "4vVcaf4nNWdR", - "colab": {} + "id": "4vVcaf4nNWdR" }, "source": [ "is_prime2(27)" @@ -3873,7 +3791,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "OpfJdTpDNWdV" }, "source": [ @@ -3883,7 +3800,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "K5hLnLVZJXXv" }, "source": [ @@ -3893,7 +3809,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "UxCgXtLgIEEf" }, "source": [ @@ -3907,9 +3822,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "3KDqoGkGIEEf", - "colab": {} + "id": "3KDqoGkGIEEf" }, "source": [ "# Once your have verified your answer please uncomment the line below and run it, this will save your code \n", @@ -3931,7 +3844,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "LHJ8OPspOM6v" }, "source": [ @@ -3943,9 +3855,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "2_p-4eSUOM6w", - "colab": {} + "id": "2_p-4eSUOM6w" }, "source": [ "print('Hello)" @@ -3956,7 +3866,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "YAw5d8J3OM61" }, "source": [ @@ -3970,7 +3879,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "BH3W9o4jOM62" }, "source": [ @@ -3995,9 +3903,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "d16XniIaOM64", - "colab": {} + "id": "d16XniIaOM64" }, "source": [ "try:\n", @@ -4016,7 +3922,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "veniFyBbOM69" }, "source": [ @@ -4026,9 +3931,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "DUUZn6mHOM69", - "colab": {} + "id": "DUUZn6mHOM69" }, "source": [ "try:\n", @@ -4047,7 +3950,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "Hk_N9KNzOM7D" }, "source": [ @@ -4059,9 +3961,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "86ypth81OM7E", - "colab": {} + "id": "86ypth81OM7E" }, "source": [ "try:\n", @@ -4080,7 +3980,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "lCAcBb9IOM7M" }, "source": [ @@ -4101,9 +4000,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "11uq4IIYOM7O", - "colab": {} + "id": "11uq4IIYOM7O" }, "source": [ "try:\n", @@ -4119,7 +4016,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "xWSjapK7OM7Y" }, "source": [ @@ -4129,9 +4025,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "eRyp48dYOM7a", - "colab": {} + "id": "eRyp48dYOM7a" }, "source": [ "def askint():\n", @@ -4150,9 +4044,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "oOpUzWc6OM7k", - "colab": {} + "id": "oOpUzWc6OM7k" }, "source": [ "askint()" @@ -4163,9 +4055,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "DRdDnSXMOM7z", - "colab": {} + "id": "DRdDnSXMOM7z" }, "source": [ "askint()" @@ -4176,7 +4066,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "U7NSCfOoOM76" }, "source": [ @@ -4186,9 +4075,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "a9A4mdRYOM78", - "colab": {} + "id": "a9A4mdRYOM78" }, "source": [ "def askint():\n", @@ -4207,9 +4094,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "dgyMsjl2OM8D", - "colab": {} + "id": "dgyMsjl2OM8D" }, "source": [ "askint()" @@ -4220,7 +4105,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "KC6gX2SMOM8H" }, "source": [ @@ -4230,9 +4114,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "r7jC8D4GOM8I", - "colab": {} + "id": "r7jC8D4GOM8I" }, "source": [ "def askint():\n", @@ -4255,9 +4137,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "xc6saFw4OM8N", - "colab": {} + "id": "xc6saFw4OM8N" }, "source": [ "askint()" @@ -4268,7 +4148,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "tqlEV-zQOM8R" }, "source": [ @@ -4280,9 +4159,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "K4g8YusIOM8S", - "colab": {} + "id": "K4g8YusIOM8S" }, "source": [ "def askint():\n", @@ -4305,9 +4182,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "E11t6GKuOM8W", - "colab": {} + "id": "E11t6GKuOM8W" }, "source": [ "askint()" @@ -4318,7 +4193,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "vaBOcf3wKmnq" }, "source": [ @@ -4328,7 +4202,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "R03RpvhvKbJC" }, "source": [ @@ -4338,9 +4211,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "zysaDxeoKbJC", - "colab": {} + "id": "zysaDxeoKbJC" }, "source": [ "# Once your have verified your answer please uncomment the line below and run it, this will save your code \n", @@ -4361,7 +4232,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "IUBg9zS8GT96" }, "source": [ @@ -4371,7 +4241,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "EZGgT39kGT-Y" }, "source": [ @@ -4389,9 +4258,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "pINzCtawGT-Z", - "colab": {} + "id": "pINzCtawGT-Z" }, "source": [ "# import the library\n", @@ -4403,9 +4270,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "wOBwO2RiGT-c", - "colab": {} + "id": "wOBwO2RiGT-c" }, "source": [ "# use it (ceiling rounding)\n", @@ -4417,7 +4282,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "B__qpOe-GT-o" }, "source": [ @@ -4428,7 +4292,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "UynSepC2cLfX" }, "source": [ @@ -4438,9 +4301,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "j_Y4057OGT98", - "colab": {} + "id": "j_Y4057OGT98" }, "source": [ "%%writefile myfile.py\n", @@ -4454,7 +4315,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "aoUBNiqiGT-C" }, "source": [ @@ -4469,9 +4329,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "dSv_ahmsGT-C", - "colab": {} + "id": "dSv_ahmsGT-C" }, "source": [ "%%writefile myfile2.py\n", @@ -4485,7 +4343,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "jZQOviqScRNu" }, "source": [ @@ -4500,7 +4357,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "hfnOwvD1GT-G" }, "source": [ @@ -4512,9 +4368,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "sVx44Sb9GT-G", - "colab": {} + "id": "sVx44Sb9GT-G" }, "source": [ "! python myfile2.py" @@ -4525,7 +4379,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "VRgQSGckGT-J" }, "source": [ @@ -4535,9 +4388,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "x4dy5kZeGT-K", - "colab": {} + "id": "x4dy5kZeGT-K" }, "source": [ "import myfile\n", @@ -4549,7 +4400,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "anK1GyS5GT-N" }, "source": [ @@ -4559,7 +4409,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "UxlbVOqlGT-O" }, "source": [ @@ -4570,9 +4419,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "1x1oE-KtGT-P", - "colab": {} + "id": "1x1oE-KtGT-P" }, "source": [ "%%writefile myfile3.py\n", @@ -4587,7 +4434,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "F5HEmqPKGT-S" }, "source": [ @@ -4598,9 +4444,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "fyJeVNs8GT-U", - "colab": {} + "id": "fyJeVNs8GT-U" }, "source": [ "! python myfile3.py 21" @@ -4611,7 +4455,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "WaU1qym5GT-Y" }, "source": [ @@ -4621,7 +4464,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "KWdrfQP2GT-g" }, "source": [ @@ -4634,9 +4476,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "Frdlk-C3GT-g", - "colab": {} + "id": "Frdlk-C3GT-g" }, "source": [ "print(dir(math))" @@ -4647,7 +4487,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "kV9kfcvBGT-j" }, "source": [ @@ -4658,9 +4497,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "nQfohp4BGT-l", - "colab": {} + "id": "nQfohp4BGT-l" }, "source": [ "help(math.ceil)" @@ -4671,7 +4508,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "YFiS7660_YlX" }, "source": [ @@ -4688,9 +4524,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "rZyb1oyrGT-o", - "colab": {} + "id": "rZyb1oyrGT-o" }, "source": [ "# Just an example, this won't work\n", @@ -4702,9 +4536,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "nAblu0pxGT-r", - "colab": {} + "id": "nAblu0pxGT-r" }, "source": [ "# OR could do it this way\n", @@ -4716,7 +4548,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "_b2Kn1ytGT-w" }, "source": [ @@ -4728,9 +4559,7 @@ { "cell_type": "code", "metadata": { - "colab_type": "code", - "id": "d0NNLlkQGT-w", - "colab": {} + "id": "d0NNLlkQGT-w" }, "source": [ "__init__.py:\n", @@ -4743,7 +4572,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "cJiazN8PJ6Wz" }, "source": [ @@ -4755,7 +4583,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "kkhCZ9fNLxRt" }, "source": [ @@ -4765,7 +4592,6 @@ { "cell_type": "markdown", "metadata": { - "colab_type": "text", "id": "zc_kzXmgMTge" }, "source": [ @@ -4777,8 +4603,7 @@ { "cell_type": "markdown", "metadata": { - "id": "FqS9ZqyneIS_", - "colab_type": "text" + "id": "FqS9ZqyneIS_" }, "source": [ "## Submission\n", @@ -4788,9 +4613,7 @@ { "cell_type": "code", "metadata": { - "id": "lQLSe4cteIS_", - "colab_type": "code", - "colab": {} + "id": "lQLSe4cteIS_" }, "source": [ "from google.colab import files\n",