diff --git a/lists.ipynb b/lists.ipynb index b766735..c32380d 100644 --- a/lists.ipynb +++ b/lists.ipynb @@ -37,6 +37,7 @@ { "cell_type": "code", "execution_count": 2, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -47,6 +48,15 @@ ] } ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Alcman', 'Sappho', 'Alcaeus', 'Anacreon', 'Stesichorus', 'Ibycus', 'Simonides', 'Bacchylides', 'Pindar']\n" + ] + } + ], "source": [ "print(lyric_poets)" ] @@ -60,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -77,13 +87,13 @@ " 'Pindar']" ] }, - "execution_count": 3, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "lyric_poets" + "lyric_poets " ] }, { @@ -97,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -106,7 +116,7 @@ "'Alcman'" ] }, - "execution_count": 5, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -124,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -133,7 +143,7 @@ "str" ] }, - "execution_count": 6, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -151,7 +161,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -160,7 +170,7 @@ "'alcman'" ] }, - "execution_count": 7, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -171,7 +181,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -180,7 +190,7 @@ "'ALCMAN'" ] }, - "execution_count": 8, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -198,7 +208,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -207,7 +217,7 @@ "'Pindar'" ] }, - "execution_count": 9, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -225,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -234,7 +244,7 @@ "'Pindar'" ] }, - "execution_count": 10, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -252,7 +262,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -261,7 +271,7 @@ "'Pindar'" ] }, - "execution_count": 11, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -279,7 +289,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -288,7 +298,7 @@ "'Bacchylides'" ] }, - "execution_count": 12, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -375,7 +385,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -392,7 +402,7 @@ " 'Pindar']" ] }, - "execution_count": 16, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -411,7 +421,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -420,7 +430,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -438,7 +448,7 @@ " 'Horace']" ] }, - "execution_count": 18, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -499,7 +509,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -518,7 +528,7 @@ " 'Horace']" ] }, - "execution_count": 23, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -537,7 +547,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -557,7 +567,7 @@ " 'Homer']" ] }, - "execution_count": 24, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -576,7 +586,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ @@ -626,7 +636,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -638,6 +648,16 @@ ] } ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I most recently taught in S2022.\n", + "I also taught in F2018, S2019, F2019, S2020, F2021.\n" + ] + } + ], "source": [ "teaching_semesters = [\"F2018\", \"S2019\", \"F2019\", \"S2020\", \"F2021\", \"S2022\"]\n", "\n", @@ -663,7 +683,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -672,47 +692,7 @@ "['F2018', 'S2019', 'F2019', 'S2020', 'F2021']" ] }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "teaching_semesters" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'F2021'" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "teaching_semesters.pop()" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['F2018', 'S2019', 'F2019', 'S2020']" - ] - }, - "execution_count": 30, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -730,7 +710,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -739,16 +719,16 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['F2018', 'S2019', 'F2019']" + "['F2018', 'S2019', 'F2019', 'F2021']" ] }, - "execution_count": 32, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -775,7 +755,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -784,7 +764,7 @@ "[3, 4, 1, 5, -1, 8]" ] }, - "execution_count": 33, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -796,7 +776,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -805,7 +785,7 @@ "[-1, 1, 3, 4, 5, 8]" ] }, - "execution_count": 34, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -824,7 +804,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -833,7 +813,7 @@ "[3, 4, 1, 5, -1, 8]" ] }, - "execution_count": 35, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -845,14 +825,14 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[8, 5, 4, 3, 1, -1]\n", + "[-1, 1, 3, 4, 5, 8]\n", "[3, 4, 1, 5, -1, 8]\n" ] } @@ -873,7 +853,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -882,7 +862,7 @@ "[8, -1, 5, 1, 4, 3]" ] }, - "execution_count": 38, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -908,7 +888,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -917,7 +897,7 @@ "6" ] }, - "execution_count": 39, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -937,7 +917,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -947,7 +927,7 @@ "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[41], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmy_list\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m6\u001b[39;49m\u001b[43m]\u001b[49m\n", + "Cell \u001b[0;32mIn[30], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmy_list\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m6\u001b[39;49m\u001b[43m]\u001b[49m\n", "\u001b[0;31mIndexError\u001b[0m: list index out of range" ] } @@ -965,7 +945,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -974,7 +954,7 @@ "3" ] }, - "execution_count": 44, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -1019,10 +999,218 @@ "\n", "Complete Exercise 3-8 in Matthes (2023, p. 45)." ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "destinations = [\"greece\", \"turkey\", \"japan\", \"germany\", \"new zealand\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['greece', 'turkey', 'japan', 'germany', 'new zealand']\n" + ] + } + ], + "source": [ + "print(destinations)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['germany', 'greece', 'japan', 'new zealand', 'turkey']\n" + ] + } + ], + "source": [ + "print(sorted(destinations))" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['greece', 'turkey', 'japan', 'germany', 'new zealand']\n" + ] + } + ], + "source": [ + "print(destinations)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['turkey', 'new zealand', 'japan', 'greece', 'germany']\n" + ] + } + ], + "source": [ + "print(sorted(destinations, reverse=True))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['greece', 'turkey', 'japan', 'germany', 'new zealand']\n" + ] + } + ], + "source": [ + "print(destinations)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['new zealand', 'germany', 'japan', 'turkey', 'greece']\n" + ] + } + ], + "source": [ + "destinations.reverse()\n", + "print(destinations)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['greece', 'turkey', 'japan', 'germany', 'new zealand']\n" + ] + } + ], + "source": [ + "destinations.reverse()\n", + "print(destinations)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['germany', 'greece', 'japan', 'new zealand', 'turkey']\n" + ] + } + ], + "source": [ + "destinations.sort()\n", + "print(destinations)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['turkey', 'new zealand', 'japan', 'greece', 'germany']\n" + ] + } + ], + "source": [ + "destinations.sort(reverse=True)\n", + "print(destinations)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['greece', 'turkey', 'japan', 'germany', 'new zealand']" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "destinations.reverse()\n", + "destinations " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['greece', 'turkey', 'japan', 'germany', 'new zealand']" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "destinations" + ] } ], "metadata": { "kernelspec": { + "display_name": "Python 3", "display_name": "Python 3", "language": "python", "name": "python3" @@ -1038,6 +1226,7 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.1" + "version": "3.12.1" } }, "nbformat": 4,