From a69fd118f4efee9521547b500c00978cf5c60b42 Mon Sep 17 00:00:00 2001 From: laurenlangbort <119360535+laurenlangbort@users.noreply.github.com> Date: Mon, 3 Feb 2025 05:03:35 +0000 Subject: [PATCH 1/3] create list of places, print list of places, reverse list of places, and sort list of places --- lists.ipynb | 208 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 147 insertions(+), 61 deletions(-) diff --git a/lists.ipynb b/lists.ipynb index 38de076..03a0db4 100644 --- a/lists.ipynb +++ b/lists.ipynb @@ -97,7 +97,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -106,7 +106,7 @@ "'Alcman'" ] }, - "execution_count": 5, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -124,7 +124,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -133,7 +133,7 @@ "str" ] }, - "execution_count": 6, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -151,7 +151,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -160,7 +160,7 @@ "'alcman'" ] }, - "execution_count": 7, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -171,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -180,7 +180,7 @@ "'ALCMAN'" ] }, - "execution_count": 8, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -198,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -207,7 +207,7 @@ "'Pindar'" ] }, - "execution_count": 9, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -225,7 +225,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -234,7 +234,7 @@ "'Pindar'" ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -252,7 +252,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -261,7 +261,7 @@ "'Pindar'" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -279,7 +279,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -288,7 +288,7 @@ "'Bacchylides'" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -306,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -315,7 +315,7 @@ "'Alcman'" ] }, - "execution_count": 13, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -326,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -335,7 +335,7 @@ "'Stesichorus'" ] }, - "execution_count": 14, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -346,7 +346,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -355,7 +355,7 @@ "'Stesichorus'" ] }, - "execution_count": 15, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -375,7 +375,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -392,7 +392,7 @@ " 'Pindar']" ] }, - "execution_count": 16, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -411,7 +411,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -420,7 +420,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -438,7 +438,7 @@ " 'Horace']" ] }, - "execution_count": 18, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -449,7 +449,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -463,7 +463,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -481,7 +481,7 @@ " 'Horace']" ] }, - "execution_count": 22, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -499,7 +499,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -518,7 +518,7 @@ " 'Horace']" ] }, - "execution_count": 23, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -537,7 +537,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -557,7 +557,7 @@ " 'Homer']" ] }, - "execution_count": 24, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -576,7 +576,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -585,7 +585,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -604,7 +604,7 @@ " 'Horace']" ] }, - "execution_count": 26, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -626,7 +626,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -663,7 +663,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -672,7 +672,7 @@ "['F2018', 'S2019', 'F2019', 'S2020', 'F2021']" ] }, - "execution_count": 28, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -683,7 +683,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -692,7 +692,7 @@ "'F2021'" ] }, - "execution_count": 29, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -703,7 +703,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -712,7 +712,7 @@ "['F2018', 'S2019', 'F2019', 'S2020']" ] }, - "execution_count": 30, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -730,7 +730,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 28, "metadata": {}, "outputs": [], "source": [ @@ -739,7 +739,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -748,7 +748,7 @@ "['F2018', 'S2019', 'F2019']" ] }, - "execution_count": 32, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -775,7 +775,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -784,7 +784,7 @@ "[3, 4, 1, 5, -1, 8]" ] }, - "execution_count": 33, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -796,7 +796,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -805,7 +805,7 @@ "[-1, 1, 3, 4, 5, 8]" ] }, - "execution_count": 34, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -824,7 +824,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -833,7 +833,7 @@ "[3, 4, 1, 5, -1, 8]" ] }, - "execution_count": 35, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -845,14 +845,14 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 33, "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 +873,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -882,7 +882,7 @@ "[8, -1, 5, 1, 4, 3]" ] }, - "execution_count": 38, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -908,7 +908,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -917,7 +917,7 @@ "6" ] }, - "execution_count": 39, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -937,7 +937,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -947,7 +947,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[36], 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" ] } @@ -1019,6 +1019,92 @@ "\n", "Complete Exercise 3-8 in Matthes (2023, p. 45)." ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Iceland', 'Bora Bora', 'Maldives', 'Thailand', 'Bali']\n" + ] + } + ], + "source": [ + "places = [\"Iceland\", \"Bora Bora\", \"Maldives\", \"Thailand\", \"Bali\"] \n", + "print(places)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Bali', 'Bora Bora', 'Iceland', 'Maldives', 'Thailand']\n" + ] + } + ], + "source": [ + "print(sorted(places))" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Iceland', 'Bora Bora', 'Maldives', 'Thailand', 'Bali']\n" + ] + } + ], + "source": [ + "print(places)" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Thailand', 'Maldives', 'Iceland', 'Bora Bora', 'Bali']\n" + ] + } + ], + "source": [ + "print(sorted(places, reverse=True))" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Iceland', 'Bora Bora', 'Maldives', 'Thailand', 'Bali']\n" + ] + } + ], + "source": [ + "print(places)" + ] } ], "metadata": { From dd02aa727c0de4f9f76fd37cf9555f6771d144a4 Mon Sep 17 00:00:00 2001 From: laurenlangbort <119360535+laurenlangbort@users.noreply.github.com> Date: Mon, 3 Feb 2025 05:05:01 +0000 Subject: [PATCH 2/3] reverse list with .reverse() --- lists.ipynb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lists.ipynb b/lists.ipynb index 03a0db4..c2245fb 100644 --- a/lists.ipynb +++ b/lists.ipynb @@ -1022,7 +1022,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -1105,6 +1105,24 @@ "source": [ "print(places)" ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Bali', 'Thailand', 'Maldives', 'Bora Bora', 'Iceland']\n" + ] + } + ], + "source": [ + "places.reverse()\n", + "print(places)" + ] } ], "metadata": { From f2c2ae687de318f1c430fd4da5597814c8100b36 Mon Sep 17 00:00:00 2001 From: laurenlangbort <119360535+laurenlangbort@users.noreply.github.com> Date: Mon, 3 Feb 2025 05:06:27 +0000 Subject: [PATCH 3/3] sort and reverse places list --- lists.ipynb | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/lists.ipynb b/lists.ipynb index c2245fb..65c45f3 100644 --- a/lists.ipynb +++ b/lists.ipynb @@ -1123,6 +1123,60 @@ "places.reverse()\n", "print(places)" ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Iceland', 'Bora Bora', 'Maldives', 'Thailand', 'Bali']\n" + ] + } + ], + "source": [ + "places.reverse()\n", + "print(places)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Bali', 'Bora Bora', 'Iceland', 'Maldives', 'Thailand']\n" + ] + } + ], + "source": [ + "places.sort()\n", + "print(places)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Thailand', 'Maldives', 'Iceland', 'Bora Bora', 'Bali']\n" + ] + } + ], + "source": [ + "places.sort(reverse=True)\n", + "print(places)" + ] } ], "metadata": {