diff --git a/lists.ipynb b/lists.ipynb index 38de076..0c24e7d 100644 --- a/lists.ipynb +++ b/lists.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -77,7 +77,7 @@ " 'Pindar']" ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -119,7 +119,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "What is the `type` of `lyric_poets[0]`?" + "What is the `type` of `lyric_poets[0]`?\n", + "str" ] }, { @@ -1019,6 +1020,137 @@ "\n", "Complete Exercise 3-8 in Matthes (2023, p. 45)." ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Paris', 'Beijing', 'Lima', 'Auckland', 'Nouakchott']\n" + ] + } + ], + "source": [ + "interesting_places = [\"Paris\", \"Beijing\", \"Lima\", \"Auckland\", \"Nouakchott\"]\n", + "print (interesting_places)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Auckland', 'Beijing', 'Lima', 'Nouakchott', 'Paris']\n", + "['Paris', 'Beijing', 'Lima', 'Auckland', 'Nouakchott']\n" + ] + } + ], + "source": [ + "print(sorted(interesting_places))\n", + "print(interesting_places)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Paris', 'Nouakchott', 'Lima', 'Beijing', 'Auckland']\n", + "['Paris', 'Beijing', 'Lima', 'Auckland', 'Nouakchott']\n" + ] + } + ], + "source": [ + "print(sorted(interesting_places, reverse=True))\n", + "print(interesting_places)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None\n", + "['Nouakchott', 'Auckland', 'Lima', 'Beijing', 'Paris']\n" + ] + } + ], + "source": [ + "print(interesting_places.reverse())\n", + "print(interesting_places)" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None\n", + "['Paris', 'Beijing', 'Lima', 'Auckland', 'Nouakchott']\n" + ] + } + ], + "source": [ + "print(interesting_places.reverse())\n", + "print(interesting_places)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "None\n", + "['Auckland', 'Beijing', 'Lima', 'Nouakchott', 'Paris']\n" + ] + } + ], + "source": [ + "interesting_places.sort()\n", + "print(interesting_places)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Paris', 'Nouakchott', 'Lima', 'Beijing', 'Auckland']\n" + ] + } + ], + "source": [ + "interesting_places.sort(reverse=True)\n", + "print(interesting_places)" + ] } ], "metadata": {