<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction\n",
    "\n",
    "You have already seen that when you change the input value to a function, you often get a different output.  For instance, consider an `add_five()` function that just adds five to any number and returns the result.  Then `add_five(7)` will return an output of 12 (=7+5), and `add_five(8)` will return an output of 13 (=8+5).  Note that no matter what the input is, the action that the function performs is always the same: it always adds five.\n",
    "\n",
    "But you might instead need a function that performs an action that depends on the input.  For instance, you might need a function `add_three_or_eight()` that adds three if the input is less than 10, and adds eight if the input is 10 or more.  Then `add_three_or_eight(1)` will return 4 (= 1+3), but `add_three_or_eight(11)` will return 19 (=11+8).  In this case, the action that the function performs varies with the input.\n",
    "\n",
    "In this lesson, you will learn how to use conditions and conditional statements to modify how your functions run.\n",
    "\n",
    "# Conditions\n",
    "\n",
    "In programming, **conditions** are statements that are either `True` or `False`.  There are many different ways to write conditions in Python, but some of the most common ways of writing conditions just compare two different values.  For instance, you can check if 2 is greater than 3."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.822463Z",
     "iopub.status.busy": "2022-03-14T18:49:02.822109Z",
     "iopub.status.idle": "2022-03-14T18:49:02.854066Z",
     "shell.execute_reply": "2022-03-14T18:49:02.853294Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.822378Z"
    }
   },
   "outputs": [],
   "source": [
    "print(2 > 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Python identifies this as False, since 2 is not greater than 3.\n",
    "\n",
    "You can also use conditions to compare the values of variables.  In the next code cell, `var_one` has a value of 1, and `var_two` has a value of two.  In the conditions, we check if `var_one` is less than 1 (which is `False`), and we check if `var_two` is greater than or equal to `var_one` (which is `True`)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.856193Z",
     "iopub.status.busy": "2022-03-14T18:49:02.855721Z",
     "iopub.status.idle": "2022-03-14T18:49:02.861321Z",
     "shell.execute_reply": "2022-03-14T18:49:02.860403Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.856158Z"
    }
   },
   "outputs": [],
   "source": [
    "var_one = 1\n",
    "var_two = 2\n",
    "\n",
    "print(var_one < 1)\n",
    "print(var_two >= var_one)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For a list of common symbols you can use to construct conditions, check out the chart below.\n",
    "\n",
    "<table style=\"width: 100%;\">\n",
    "<tbody>\n",
    "<tr><th><b>Symbol</b></th><th><b>Meaning</b></th></tr>\n",
    "<tr>\n",
    "<td>==</td>\n",
    "<td>equals</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>!=</td>\n",
    "<td>does not equal</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#60;</td>\n",
    "<td>less than</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#60;=</td>\n",
    "<td>less than or equal to</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#62;</td>\n",
    "<td>greater than</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#62;=</td>\n",
    "<td>greater than or equal to</td>\n",
    "</tr>\n",
    "</tbody>\n",
    "</table>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Important Note**: When you check two values are equal, make sure you use the == sign, and not the = sign.  \n",
    "- `var_one==1` checks if the value of `var_one` is 1, but \n",
    "- `var_one=1` sets the value of `var_one` to 1."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Conditional statements\n",
    "\n",
    "**Conditional statements** use conditions to modify how your function runs.  They check the value of a condition, and if the condition evaluates to `True`, then a certain block of code is executed.  (Otherwise, if the condition is `False`, then the code is not run.)  \n",
    "\n",
    "You will see several examples of this in the following sections.\n",
    "\n",
    "## \"if\" statements\n",
    "\n",
    "The simplest type of conditional statement is an \"if\" statement.  You can see an example of this in the `evaluate_temp()` function below.  The function accepts a body temperature (in Celcius) as input.\n",
    "- Initially, `message` is set to `\"Normal temperature\"`.  \n",
    "- Then, if `temp > 38` is `True` (e.g., the body temperature is greater than 38°C), the message is updated to `\"Fever!\"`.  Otherwise, if `temp > 38` is False, then the message is not updated.\n",
    "- Finally, `message` is returned by the function.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.863228Z",
     "iopub.status.busy": "2022-03-14T18:49:02.862629Z",
     "iopub.status.idle": "2022-03-14T18:49:02.875031Z",
     "shell.execute_reply": "2022-03-14T18:49:02.874011Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.863181Z"
    }
   },
   "outputs": [],
   "source": [
    "def evaluate_temp(temp):\n",
    "    # Set an initial message\n",
    "    message = \"Normal temperature.\"\n",
    "    # Update value of message only if temperature greater than 38\n",
    "    if temp > 38:\n",
    "        message = \"Fever!\"\n",
    "    return message"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the next code cell, we call the function, where the temperature is 37°C. The message is `\"Normal temperature\"`, because the temperature is greater than 38°C (`temp > 38` evaluates to `False`) in this case.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.876814Z",
     "iopub.status.busy": "2022-03-14T18:49:02.876461Z",
     "iopub.status.idle": "2022-03-14T18:49:02.890687Z",
     "shell.execute_reply": "2022-03-14T18:49:02.889992Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.876778Z"
    }
   },<commit_msg>fix typo in itp<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction\n",
    "\n",
    "You have already seen that when you change the input value to a function, you often get a different output.  For instance, consider an `add_five()` function that just adds five to any number and returns the result.  Then `add_five(7)` will return an output of 12 (=7+5), and `add_five(8)` will return an output of 13 (=8+5).  Note that no matter what the input is, the action that the function performs is always the same: it always adds five.\n",
    "\n",
    "But you might instead need a function that performs an action that depends on the input.  For instance, you might need a function `add_three_or_eight()` that adds three if the input is less than 10, and adds eight if the input is 10 or more.  Then `add_three_or_eight(1)` will return 4 (= 1+3), but `add_three_or_eight(11)` will return 19 (=11+8).  In this case, the action that the function performs varies with the input.\n",
    "\n",
    "In this lesson, you will learn how to use conditions and conditional statements to modify how your functions run.\n",
    "\n",
    "# Conditions\n",
    "\n",
    "In programming, **conditions** are statements that are either `True` or `False`.  There are many different ways to write conditions in Python, but some of the most common ways of writing conditions just compare two different values.  For instance, you can check if 2 is greater than 3."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.822463Z",
     "iopub.status.busy": "2022-03-14T18:49:02.822109Z",
     "iopub.status.idle": "2022-03-14T18:49:02.854066Z",
     "shell.execute_reply": "2022-03-14T18:49:02.853294Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.822378Z"
    }
   },
   "outputs": [],
   "source": [
    "print(2 > 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Python identifies this as False, since 2 is not greater than 3.\n",
    "\n",
    "You can also use conditions to compare the values of variables.  In the next code cell, `var_one` has a value of 1, and `var_two` has a value of two.  In the conditions, we check if `var_one` is less than 1 (which is `False`), and we check if `var_two` is greater than or equal to `var_one` (which is `True`)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.856193Z",
     "iopub.status.busy": "2022-03-14T18:49:02.855721Z",
     "iopub.status.idle": "2022-03-14T18:49:02.861321Z",
     "shell.execute_reply": "2022-03-14T18:49:02.860403Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.856158Z"
    }
   },
   "outputs": [],
   "source": [
    "var_one = 1\n",
    "var_two = 2\n",
    "\n",
    "print(var_one < 1)\n",
    "print(var_two >= var_one)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For a list of common symbols you can use to construct conditions, check out the chart below.\n",
    "\n",
    "<table style=\"width: 100%;\">\n",
    "<tbody>\n",
    "<tr><th><b>Symbol</b></th><th><b>Meaning</b></th></tr>\n",
    "<tr>\n",
    "<td>==</td>\n",
    "<td>equals</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>!=</td>\n",
    "<td>does not equal</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#60;</td>\n",
    "<td>less than</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#60;=</td>\n",
    "<td>less than or equal to</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#62;</td>\n",
    "<td>greater than</td>\n",
    "</tr>\n",
    "<tr>\n",
    "<td>&#62;=</td>\n",
    "<td>greater than or equal to</td>\n",
    "</tr>\n",
    "</tbody>\n",
    "</table>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Important Note**: When you check two values are equal, make sure you use the == sign, and not the = sign.  \n",
    "- `var_one==1` checks if the value of `var_one` is 1, but \n",
    "- `var_one=1` sets the value of `var_one` to 1."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Conditional statements\n",
    "\n",
    "**Conditional statements** use conditions to modify how your function runs.  They check the value of a condition, and if the condition evaluates to `True`, then a certain block of code is executed.  (Otherwise, if the condition is `False`, then the code is not run.)  \n",
    "\n",
    "You will see several examples of this in the following sections.\n",
    "\n",
    "## \"if\" statements\n",
    "\n",
    "The simplest type of conditional statement is an \"if\" statement.  You can see an example of this in the `evaluate_temp()` function below.  The function accepts a body temperature (in Celcius) as input.\n",
    "- Initially, `message` is set to `\"Normal temperature\"`.  \n",
    "- Then, if `temp > 38` is `True` (e.g., the body temperature is greater than 38°C), the message is updated to `\"Fever!\"`.  Otherwise, if `temp > 38` is False, then the message is not updated.\n",
    "- Finally, `message` is returned by the function.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.863228Z",
     "iopub.status.busy": "2022-03-14T18:49:02.862629Z",
     "iopub.status.idle": "2022-03-14T18:49:02.875031Z",
     "shell.execute_reply": "2022-03-14T18:49:02.874011Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.863181Z"
    }
   },
   "outputs": [],
   "source": [
    "def evaluate_temp(temp):\n",
    "    # Set an initial message\n",
    "    message = \"Normal temperature.\"\n",
    "    # Update value of message only if temperature greater than 38\n",
    "    if temp > 38:\n",
    "        message = \"Fever!\"\n",
    "    return message"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the next code cell, we call the function, where the temperature is 37°C. The message is `\"Normal temperature\"`, because the temperature is less than 38°C (`temp > 38` evaluates to `False`) in this case.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-03-14T18:49:02.876814Z",
     "iopub.status.busy": "2022-03-14T18:49:02.876461Z",
     "iopub.status.idle": "2022-03-14T18:49:02.890687Z",
     "shell.execute_reply": "2022-03-14T18:49:02.889992Z",
     "shell.execute_reply.started": "2022-03-14T18:49:02.876778Z"
    }
   },
{'fraction_non_alphanumeric': 0.17879853370240142, 'fraction_numerical': 0.06987356923767488, 'mean_word_length': 2.952690715552927, 'pattern_counts': {'":': 122, '<': 105, '<?xml version=': 0, '>': 115, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6951298', 'n_tokens_mistral': 5340, 'n_tokens_neox': 4805, 'n_words': 1403}