diff --git a/conditionals.ipynb b/conditionals.ipynb index 5c1392a..a366fad 100644 --- a/conditionals.ipynb +++ b/conditionals.ipynb @@ -41,9 +41,23 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Agamemnon\n", + "Menelaus\n", + "Ajax\n", + "Odysseus\n", + "Achilles\n", + "Achilles, you're the best!\n", + "Patroclus\n" + ] + } + ], "source": [ "achaeans = [\"Agamemnon\", \"Menelaus\", \"Ajax\", \"Odysseus\", \"Achilles\", \"Patroclus\"]\n", "\n", @@ -107,9 +121,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "odysseus = \"Odysseus\"\n", "achilles = \"Achilles\"\n", @@ -119,18 +144,40 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "achilles != odysseus" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "achilles == odysseus" ] @@ -144,9 +191,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "achilles.lower() == \"Achilles\"" ] @@ -169,9 +227,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number_of_achaeans = 200_000\n", "number_of_trojans = 100_000\n", @@ -226,9 +295,20 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number_of_gods = 12\n", "\n", @@ -237,27 +317,60 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number_of_gods > number_of_trojans or number_of_trojans < number_of_achaeans" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number_of_trojans > number_of_achaeans and number_of_trojans > number_of_gods" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "number_of_trojans > number_of_achaeans or number_of_trojans > number_of_gods" ] @@ -273,18 +386,40 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"Achilles\" in achaeans" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"Hector\" in achaeans" ] @@ -302,9 +437,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Andromache, you do not deserve what's about to happen to you and your family.\n" + ] + } + ], "source": [ "trojans = [\"Priam\", \"Hector\", \"Paris\", \"Aeneas\", \"Cassandra\", \"Hecuba\", \"Andromache\"]\n", "\n", @@ -329,9 +472,18 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Andromache, you do not deserve what's about to happen to you and your family.\n", + "Paris! So that's where my leopard-print suit went!\n" + ] + } + ], "source": [ "if \"Achilles\" in trojans:\n", " print(\"Whoa, Achilles, what are you doing there!?\")\n", @@ -356,11 +508,87 @@ "5. Collect all of the dialogue spoken by Socrates in a single string (recall multiline strings with `\"\"\"`). Do likewise for Phaedrus.\n", "6. Use `len()` and a comparison operator to confirm that Socrates speaks more than Phaedrus." ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Socrates is definitely mortal.\n", + "Phaedrus is definitely mortal.\n", + "Theuth is a god!\n", + "Thamus is a god!\n", + "Ammon is a god!\n", + "There are more gods than mortals in these lists.\n", + "Socrates definitely spoke more!\n" + ] + } + ], + "source": [ + "names = [\"Socrates\", \"Phaedrus\", \"Theuth\", \"Thamus\", \"Ammon\"]\n", + "\n", + "mortals = [\"Socrates\", \"Phaedrus\"]\n", + "gods = [\"Theuth\", \"Ammon\", \"Thamus\"]\n", + "\n", + "for person in names:\n", + " if person in mortals:\n", + " print(f\"{person} is definitely mortal.\")\n", + " elif person in gods:\n", + " print(f\"{person} is a god!\")\n", + "\n", + "if len(gods) > len(mortals): \n", + " print(\"There are more gods than mortals in these lists.\")\n", + "else:\n", + " print(\"Seems there's more mortals than gods in these lists.\")\n", + "\n", + "\n", + "Socrates_dialogue = \"\"\"Anyway, I’ve heard a saying among our ancestors, but they know its\n", + "truth. But if we ourselves uncover it, would human conjectures still matter to us? Well then, I heard that at Naucratis, in Egypt, there was some one of the ancient\n", + "gods, who also has a sacred bird which they call “Ibis” — but the name of this\n", + "divinity is Theuth. He was the first to discover arithmetic and calculation, geometry and astronomy, even backgammon and dice-playing, and\n", + "especially letters.\n", + "Now at that time the king of all Egypt was Thamus in the great city of the upper\n", + "region, which the Greeks call “Egyptian Thebes” — and they call the god Ammon.\n", + "And Theuth came to his palace to show him his skills, and he said it\n", + "was necessary to distribute them among the other Egyptians — but Thamus asked\n", + "what the use of each skill was. And while Theuth went through them,\n", + "Thamus said whether each one seemed fine or not to him, censuring some and\n", + "praising others.\n", + "It is said, on the one hand, that Thamus said many such things on both sides about each skill when Theuth was explaining\n", + "them — the account of them would take a while to go through. But when it\n", + "came to letters, Theuth said, “This invention, O king, will make the Egyptians wiser\n", + "and more capable of remembering: for I have discovered a drug [pharmakon] for\n", + "memory and wisdom. And Thamus replied, “O most-skilled Theuth, one person can fashion\n", + "elements of a skill, but it’s up to someone else to judge what share of\n", + "blame and usefulness it has for those who are going to use it. And now you, since\n", + "you are the father of letters, because of your partiality, say that they have a\n", + "capability opposite to what they really do. For this will yield\n", + "forgetfulness in the souls of those who have learned it, and negligence with regard\n", + "to their memories. Because through their trust in writing — foreign markings from\n", + "outside, rather than their own remembering from within themselves.\n", + "“So you have not discovered a drug for memory but for reminding. And you furnish\n", + "your learners with what seems like wisdom, not true wisdom. For they will become\n", + "hearers-of-many-things without instruction, and they will seem to be\n", + "much-learned to you, but they will for the most part be unlearned, and they will make difficult company, since they will have become\n", + "wise-seemers instead of wise people.\"\"\"\n", + "\n", + "Phaedrus_dialogue = \"\"\" You’re talking nonsense — but tell me what you said that you heard. O Socrates, you easily make up stories about Egypt and anywhere you\n", + "want.\"\"\"\n", + "\n", + "if len(Socrates_dialogue) > len(Phaedrus_dialogue):\n", + " print(\"Socrates definitely spoke more!\")\n", + "else: \n", + " print(\"Somehow Phaedrus spoke more!\")" + ] } ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -374,7 +602,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.7" + "version": "3.12.1" } }, "nbformat": 4,