From 360d77774084a0bc11d21632716d4aaec5e2bd2d Mon Sep 17 00:00:00 2001 From: Anna Meyer <annapmeyer95@gmail.com> Date: Wed, 5 Jul 2023 10:39:40 -0500 Subject: [PATCH] review --- .../07_Strings/Exam_1_review.ipynb | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/sum23/lecture_materials/07_Strings/Exam_1_review.ipynb b/sum23/lecture_materials/07_Strings/Exam_1_review.ipynb index 3f101d4..29fa01a 100644 --- a/sum23/lecture_materials/07_Strings/Exam_1_review.ipynb +++ b/sum23/lecture_materials/07_Strings/Exam_1_review.ipynb @@ -274,6 +274,49 @@ "# Discuss: given two possible versions of a function (where one is correct),\n", "# what is the general strategy for figuring out which one is correct?" ] + }, + { + "cell_type": "markdown", + "id": "d1ba721c", + "metadata": {}, + "source": [ + "## Iteration" + ] + }, + { + "cell_type": "markdown", + "id": "851c3e95", + "metadata": {}, + "source": [ + "### Example 1 (Reimann sums)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "85e203c9", + "metadata": {}, + "outputs": [], + "source": [ + "# Let's try the values from 1 to 5\n", + "start_x = 1\n", + "end_x = 5\n", + "total_area = 0\n", + "current_x = start_x\n", + "# Try out increasing values of width, make sure to comment the other width values\n", + "# delta_x = 1\n", + "delta_x = 0.1\n", + "# delta_x = 0.01\n", + "# delta_x = 0.001\n", + "\n", + "while current_x <= end_x:\n", + " y = ??? # TODO: use f(x) defined previously\n", + " rect_area = ???\n", + " total_area += ???\n", + " current_x += delta_x\n", + " \n", + "print(\"Area found using approximation is:\", total_area)" + ] } ], "metadata": { -- GitLab