From 3559f1e3895d351bf8b246ba2d5d818b1852b9bb Mon Sep 17 00:00:00 2001 From: Anna Meyer <annapmeyer95@gmail.com> Date: Mon, 10 Jul 2023 08:58:00 -0500 Subject: [PATCH] lec 10 changes --- .../08_Lists/lec_08_lists_template.ipynb | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/sum23/lecture_materials/08_Lists/lec_08_lists_template.ipynb b/sum23/lecture_materials/08_Lists/lec_08_lists_template.ipynb index 801e1bc..d4263de 100644 --- a/sum23/lecture_materials/08_Lists/lec_08_lists_template.ipynb +++ b/sum23/lecture_materials/08_Lists/lec_08_lists_template.ipynb @@ -17,6 +17,31 @@ "import project" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Warmup: string review\n", + "# Predict the output of the following statments\n", + "name = \"Andrew\"\n", + "print(name[3])\n", + "print(name[-1])\n", + "print(name[:2])\n", + "print(name[:-1])\n", + "\n", + "# Try this: change only the last letter of the name to \"a\" so that name = \"Andrea\"\n", + "\n", + "# Takeaway:\n", + "# you cannot _______________\n", + "# because strings are ___________-\n", + "\n", + "# But what about....\n", + "name = \"Fred\" # this is called reassignment and is allowed\n", + "print(name)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -99,8 +124,15 @@ "print()\n", "\n", "# TODO: use slicing to extract only the vegetables\n", - "print()\n", - "\n", + "print()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# TODO: discuss why the following gives IndexError\n", "print(grocery_list[len(grocery_list)])" ] -- GitLab