From 998a8a3397aaf47a5c6c11176d742c3e8f7e87f5 Mon Sep 17 00:00:00 2001
From: gsingh58 <gurmail.singh@wisc.edu>
Date: Fri, 17 Feb 2023 08:23:19 -0500
Subject: [PATCH] Lec11 update

---
 .../11_Iteration-2/lec_11_Iteration_2.ipynb   |  34 ++-
 ...1_Iteration_2_template_Gurmail_lec1.ipynb} |  32 +++
 ...1_Iteration_2_template_Gurmail_lec2.ipynb} | 258 +++++++-----------
 3 files changed, 170 insertions(+), 154 deletions(-)
 rename s23/Gurmail_lecture_notes/11_Iteration-2/{lec_11_Iteration_2_template.ipynb => lec_11_Iteration_2_template_Gurmail_lec1.ipynb} (82%)
 rename s23/Gurmail_lecture_notes/11_Iteration-2/{.ipynb_checkpoints/lec_11_Iteration_2-checkpoint.ipynb => lec_11_Iteration_2_template_Gurmail_lec2.ipynb} (56%)

diff --git a/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2.ipynb b/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2.ipynb
index 1d01989..480a260 100644
--- a/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2.ipynb
+++ b/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2.ipynb
@@ -1,5 +1,37 @@
 {
  "cells": [
+  {
+   "cell_type": "markdown",
+   "id": "5117857a",
+   "metadata": {},
+   "source": [
+    "# Announcements - Friday\n",
+    "\n",
+    "* Download files for today's lecture\n",
+    "* Quiz 3 due today\n",
+    "* P4 Bad Link\n",
+    "* [Thank You](https://docs.google.com/forms/d/e/1FAIpQLSe0Zi6JFbxPIEVr7u1DJykuel-qSi7U0sBp2iR0gi6R_CArgw/viewform)\n",
+    "* [Regrade request procedure](https://piazza.com/class/ld8bqui1lgeas/post/105)\n",
+    "* Exam 1\n",
+    "  * Number 2 pencil\n",
+    "  * Room assignment via Canvas Message (before Tuesday)\n",
+    "* [Exam 1 Conflict Form](https://docs.google.com/forms/d/e/1FAIpQLScKmey733tOjLfJ2q13Np76w_4o6cFcGVyNqWZmseZH0KNp2w/viewform)\n",
+    "  * one page note sheet\n",
+    "    * put anything you want on this sheet\n",
+    "    * we will keep this sheet - make a copy if you want one\n",
+    "  * ID Card and #2 pencil\n",
+    "  * General: Wednesday February 22: 5:45 pm\n",
+    "  * McBurney: Wednesday Februrary 22 5:30 pm - If you are approved for anything other than extra time and small group testing please fill out the form\n",
+    "  * Alternate: Thursday February 23 5:45 pm \n",
+    "  * Location will be sent by email on Monday February 20\n",
+    "  * Note: Chemistry has an exam at the same time as our Wednesday exam\n",
+    "  * Note: Wednesday Evening section \n",
+    "    - alternate time 7:30 - 9:00 pm\n",
+    "    - please fill out the conflict form to get on the list for the location email\n",
+    "    - feel free to revise your conflict form if this time works better for you\n",
+    "* [The best way to study for the exam!!!](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/tree/main/s23/old_exams/exam1)"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "1fd5544f",
@@ -395,7 +427,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.9.13"
+   "version": "3.9.12"
   }
  },
  "nbformat": 4,
diff --git a/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template.ipynb b/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template_Gurmail_lec1.ipynb
similarity index 82%
rename from s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template.ipynb
rename to s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template_Gurmail_lec1.ipynb
index a6dcd87..9859674 100644
--- a/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template.ipynb
+++ b/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template_Gurmail_lec1.ipynb
@@ -1,5 +1,37 @@
 {
  "cells": [
+  {
+   "cell_type": "markdown",
+   "id": "e6f081e5",
+   "metadata": {},
+   "source": [
+    "# Announcements - Friday\n",
+    "\n",
+    "* Download files for today's lecture\n",
+    "* Quiz 3 due today\n",
+    "* P4 Bad Link\n",
+    "* [Thank You](https://docs.google.com/forms/d/e/1FAIpQLSe0Zi6JFbxPIEVr7u1DJykuel-qSi7U0sBp2iR0gi6R_CArgw/viewform)\n",
+    "* [Regrade request procedure](https://piazza.com/class/ld8bqui1lgeas/post/105)\n",
+    "* Exam 1\n",
+    "  * Number 2 pencil\n",
+    "  * Room assignment via Canvas Message (before Tuesday)\n",
+    "* [Exam 1 Conflict Form](https://docs.google.com/forms/d/e/1FAIpQLScKmey733tOjLfJ2q13Np76w_4o6cFcGVyNqWZmseZH0KNp2w/viewform)\n",
+    "  * one page note sheet\n",
+    "    * put anything you want on this sheet\n",
+    "    * we will keep this sheet - make a copy if you want one\n",
+    "  * ID Card and #2 pencil\n",
+    "  * General: Wednesday February 22: 5:45 pm\n",
+    "  * McBurney: Wednesday Februrary 22 5:30 pm - If you are approved for anything other than extra time and small group testing please fill out the form\n",
+    "  * Alternate: Thursday February 23 5:45 pm \n",
+    "  * Location will be sent by email on Monday February 20\n",
+    "  * Note: Chemistry has an exam at the same time as our Wednesday exam\n",
+    "  * Note: Wednesday Evening section \n",
+    "    - alternate time 7:30 - 9:00 pm\n",
+    "    - please fill out the conflict form to get on the list for the location email\n",
+    "    - feel free to revise your conflict form if this time works better for you\n",
+    "* [The best way to study for the exam!!!](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/tree/main/s23/old_exams/exam1)"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "cce4a7bf",
diff --git a/s23/Gurmail_lecture_notes/11_Iteration-2/.ipynb_checkpoints/lec_11_Iteration_2-checkpoint.ipynb b/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template_Gurmail_lec2.ipynb
similarity index 56%
rename from s23/Gurmail_lecture_notes/11_Iteration-2/.ipynb_checkpoints/lec_11_Iteration_2-checkpoint.ipynb
rename to s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template_Gurmail_lec2.ipynb
index 1d01989..9859674 100644
--- a/s23/Gurmail_lecture_notes/11_Iteration-2/.ipynb_checkpoints/lec_11_Iteration_2-checkpoint.ipynb
+++ b/s23/Gurmail_lecture_notes/11_Iteration-2/lec_11_Iteration_2_template_Gurmail_lec2.ipynb
@@ -2,7 +2,39 @@
  "cells": [
   {
    "cell_type": "markdown",
-   "id": "1fd5544f",
+   "id": "e6f081e5",
+   "metadata": {},
+   "source": [
+    "# Announcements - Friday\n",
+    "\n",
+    "* Download files for today's lecture\n",
+    "* Quiz 3 due today\n",
+    "* P4 Bad Link\n",
+    "* [Thank You](https://docs.google.com/forms/d/e/1FAIpQLSe0Zi6JFbxPIEVr7u1DJykuel-qSi7U0sBp2iR0gi6R_CArgw/viewform)\n",
+    "* [Regrade request procedure](https://piazza.com/class/ld8bqui1lgeas/post/105)\n",
+    "* Exam 1\n",
+    "  * Number 2 pencil\n",
+    "  * Room assignment via Canvas Message (before Tuesday)\n",
+    "* [Exam 1 Conflict Form](https://docs.google.com/forms/d/e/1FAIpQLScKmey733tOjLfJ2q13Np76w_4o6cFcGVyNqWZmseZH0KNp2w/viewform)\n",
+    "  * one page note sheet\n",
+    "    * put anything you want on this sheet\n",
+    "    * we will keep this sheet - make a copy if you want one\n",
+    "  * ID Card and #2 pencil\n",
+    "  * General: Wednesday February 22: 5:45 pm\n",
+    "  * McBurney: Wednesday Februrary 22 5:30 pm - If you are approved for anything other than extra time and small group testing please fill out the form\n",
+    "  * Alternate: Thursday February 23 5:45 pm \n",
+    "  * Location will be sent by email on Monday February 20\n",
+    "  * Note: Chemistry has an exam at the same time as our Wednesday exam\n",
+    "  * Note: Wednesday Evening section \n",
+    "    - alternate time 7:30 - 9:00 pm\n",
+    "    - please fill out the conflict form to get on the list for the location email\n",
+    "    - feel free to revise your conflict form if this time works better for you\n",
+    "* [The best way to study for the exam!!!](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-lecture-material/-/tree/main/s23/old_exams/exam1)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "id": "cce4a7bf",
    "metadata": {},
    "source": [
     "# Iteration 2\n",
@@ -14,8 +46,8 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 1,
-   "id": "e15b9d08",
+   "execution_count": null,
+   "id": "7693263d",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -24,7 +56,7 @@
   },
   {
    "cell_type": "markdown",
-   "id": "ebce36a5",
+   "id": "0b7e0914",
    "metadata": {},
    "source": [
     "## Learning Objectives\n",
@@ -36,7 +68,7 @@
   },
   {
    "cell_type": "markdown",
-   "id": "8f91daea",
+   "id": "06b520a0",
    "metadata": {},
    "source": [
     "## `break` example\n",
@@ -46,8 +78,8 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
-   "id": "5ec2099a",
+   "execution_count": null,
+   "id": "8067fa3e",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -56,36 +88,22 @@
     "    Assumes x is positive\"\"\"\n",
     "    \n",
     "    # try all divisors from 2 to sqrt(num) to check if num is prime\n",
-    "    divisor = 2\n",
-    "    while divisor <= math.sqrt(num):\n",
+    "    divisor = ???\n",
+    "    while ???:\n",
     "        # check if num is divisible by divisor\n",
-    "        if num % divisor == 0:\n",
-    "            return False\n",
-    "        divisor += 1\n",
+    "        if num % divisor == ???:\n",
+    "            return ???\n",
+    "        divisor ???\n",
     "        \n",
-    "    return True"
+    "    return ???"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
-   "id": "18f5a22c",
+   "execution_count": null,
+   "id": "2e3d3f29",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "True\n",
-      "True\n",
-      "True\n",
-      "True\n",
-      "False\n",
-      "True\n",
-      "False\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "print(is_prime(1))\n",
     "print(is_prime(2))\n",
@@ -98,77 +116,43 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
-   "id": "daca8575",
+   "execution_count": null,
+   "id": "9a28c726",
    "metadata": {},
    "outputs": [],
    "source": [
     "def has_prime(start, end):\n",
-    "    found_prime = False\n",
-    "    num = start\n",
-    "    while num <= end:\n",
-    "        if is_prime(num):\n",
-    "            print(num)\n",
-    "            found_prime = True\n",
-    "            # As soon as you find the first prime, your work \n",
-    "            # here is done, hence the break out of the loop!\n",
-    "            break\n",
-    "        num += 1\n",
-    "    return found_prime"
+    "    # TODO: write a for loop using range, to:\n",
+    "    #       1. iterate over every number from start to end\n",
+    "    #       2. call is_prime function, to determine if it is prime\n",
+    "    #       3. if you find at least one prime, has_prime should\n",
+    "    #          return True, False otherwise\n",
+    "    pass"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
-   "id": "0f7bd5ca",
+   "execution_count": null,
+   "id": "5cde0776",
    "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "False"
-      ]
-     },
-     "execution_count": 5,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
+   "outputs": [],
    "source": [
     "has_prime(14, 16)"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
-   "id": "4fd676f3",
+   "execution_count": null,
+   "id": "3a5be934",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1000003\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "True"
-      ]
-     },
-     "execution_count": 6,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
+   "outputs": [],
    "source": [
     "has_prime(1000000, 1001000)"
    ]
   },
   {
    "cell_type": "markdown",
-   "id": "dfc74fed",
+   "id": "12c14f3b",
    "metadata": {},
    "source": [
     "## `continue` example\n",
@@ -178,49 +162,41 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
-   "id": "e90b47b5",
+   "execution_count": null,
+   "id": "ef8d6e0b",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Enter an age [0-100]: 10\n",
-      "Average age of user so far is:  10.0\n",
-      "Enter an age [0-100]: 20\n",
-      "Average age of user so far is:  15.0\n",
-      "Enter an age [0-100]: 102\n",
-      "Bad input!\n",
-      "Enter an age [0-100]: q\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
-    "total = 0 # sum\n",
-    "count = 0\n",
-    "\n",
-    "while True:\n",
-    "    #Handle \"q\" input for quitting\n",
-    "    age = input(\"Enter an age [0-100]: \")\n",
-    "    if age == \"q\":\n",
-    "        break\n",
+    "# TODO: write an infinite loop using while\n",
     "\n",
-    "    age = float(age)\n",
-    "\n",
-    "    if age < 0 or age > 100:\n",
-    "        print(\"Bad input!\")\n",
-    "        continue\n",
-    "\n",
-    "    total += age\n",
-    "    count += 1\n",
-    "\n",
-    "    print(\"Average age of user so far is: \", total / count)"
+    "    # TODO: get user input for age\n",
+    "    \n",
+    "    # Goal: to compute running average\n",
+    "    # It is easy to keep track of total and number of user\n",
+    "    # inputs to compute running average\n",
+    "    \n",
+    "    # TODO: discuss what is acceptable range for age\n",
+    "    # What is the guinness world record for oldest person?\n",
+    "    \n",
+    "    # TODO: discuss where you will initialize variables to keep track\n",
+    "    # of total and number of user inputs so far and then type the\n",
+    "    # computation lines to compute updated total and running average\n",
+    "    \n",
+    "    # Now, try entering input as a large number outside of your\n",
+    "    # acceptable age range. What happens to your average?\n",
+    "    # TODO: handle this by writing a conditional and use continue,\n",
+    "    # when user enters invalid age\n",
+    "    \n",
+    "    # Finally, how do we terminate the infinite while loop\n",
+    "    # Let's accept \"q\" as user input for termination\n",
+    "    # TODO: handle that using another conditional\n",
+    "    # Think carefully about where this conditional needs to be in \n",
+    "    # terms of control flow"
    ]
   },
   {
    "cell_type": "markdown",
-   "id": "8b037e4f",
+   "id": "944cc596",
    "metadata": {},
    "source": [
     "### After lecture"
@@ -228,7 +204,7 @@
   },
   {
    "cell_type": "markdown",
-   "id": "bf87a5ac",
+   "id": "0820ba66",
    "metadata": {},
    "source": [
     "How many times is the *while loop condition line* executed?"
@@ -237,7 +213,7 @@
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "cb6bb684",
+   "id": "c3c14b7b",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -253,7 +229,7 @@
   },
   {
    "cell_type": "markdown",
-   "id": "4def9307",
+   "id": "7cf19523",
    "metadata": {},
    "source": [
     "Refactor the below function."
@@ -261,22 +237,10 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
-   "id": "9421ad49",
+   "execution_count": null,
+   "id": "a313a32f",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "False\n",
-      "True\n",
-      "False\n",
-      "True\n",
-      "False\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "def is_between(a, b, c):\n",
     "    \"\"\"Return True if b is between a and c (exclusive), \n",
@@ -303,25 +267,13 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
-   "id": "21951d05",
+   "execution_count": null,
+   "id": "7fd82ae9",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "False\n",
-      "True\n",
-      "False\n",
-      "True\n",
-      "False\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "def is_between_v2(a, b, c):\n",
-    "    return a < b < c or c < b < a\n",
+    "    return ???\n",
     "\n",
     "print(is_between_v2(1, 3, 2))   # False\n",
     "print(is_between_v2(5, 11, 20)) # True\n",
@@ -332,7 +284,7 @@
   },
   {
    "cell_type": "markdown",
-   "id": "0f71dc12",
+   "id": "ca9037f7",
    "metadata": {},
    "source": [
     "Trace the output without using Python interpreter"
@@ -341,7 +293,7 @@
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "b942d01f",
+   "id": "ec8b1b32",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -358,7 +310,7 @@
   {
    "cell_type": "code",
    "execution_count": null,
-   "id": "7743e03b",
+   "id": "74060bc4",
    "metadata": {},
    "outputs": [],
    "source": [
@@ -395,7 +347,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.9.13"
+   "version": "3.9.12"
   }
  },
  "nbformat": 4,
-- 
GitLab