diff --git a/sum23/lecture_materials/07_Strings/Exam_1_review.ipynb b/sum23/lecture_materials/07_Strings/Exam_1_review.ipynb index 3f101d4030a41e02acc8f1f83430abcaa066acfb..29fa01afcf753b93cbe29f3c4543988661a4f1db 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": {