Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
277 changes: 246 additions & 31 deletions conditionals.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 1,
"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",
Expand All @@ -63,9 +77,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"You're probably telling the truth, Agamemnon.\n",
"You're probably telling the truth, Menelaus.\n",
"You're probably telling the truth, Ajax.\n",
"I dunno if I buy that, Odysseus.\n",
"You're probably telling the truth, Achilles.\n",
"You're probably telling the truth, Patroclus.\n"
]
}
],
"source": [
"for leader in achaeans:\n",
" if leader != \"Odysseus\":\n",
Expand All @@ -83,9 +110,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"It's true!\n",
"But I provide a fallback!\n"
]
}
],
"source": [
"if True:\n",
" print(\"It's true!\")\n",
Expand All @@ -107,9 +143,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"odysseus = \"Odysseus\"\n",
"achilles = \"Achilles\"\n",
Expand All @@ -119,18 +166,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"achilles != odysseus"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"achilles == odysseus"
]
Expand All @@ -144,9 +213,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"achilles.lower() == \"Achilles\""
]
Expand All @@ -169,9 +249,20 @@
},
{
"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_achaeans = 200_000\n",
"number_of_trojans = 100_000\n",
Expand All @@ -181,9 +272,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"number_of_achaeans >= number_of_trojans"
]
Expand Down Expand Up @@ -302,9 +404,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 10,
"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",
Expand Down Expand Up @@ -356,6 +466,111 @@
"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": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Socrates is a mortal\n",
"Phaedrus is a mortal\n",
"Theuth is a god in the excerpt\n",
"Thamus is a mortal\n",
"Ammon is a god in the excerpt\n",
"There are more mortals than gods\n"
]
}
],
"source": [
"#Part one \n",
"\n",
"#Create list of names in excerpt\n",
"names = [\"Socrates\", \"Phaedrus\", \"Theuth\", \"Thamus\", \"Ammon\"]\n",
"\n",
"#Part two\n",
"mortals = [\"Socrates\", \"Phaedrus\", \"Thamus\"]\n",
"gods = [\"Theuth\", \"Ammon\"]\n",
"\n",
"\n",
"#Part 3\n",
"for name in names:\n",
" if name in mortals:\n",
" print(f\"{name} is a mortal\")\n",
" else:\n",
" print(f\"{name} is a god in the excerpt\")\n",
"\n",
"#Part 4\n",
"# Compare the lengths of gods and mortals lists\n",
"if len(gods) > len(mortals):\n",
" print(\"There are more gods than mortals\")\n",
"elif len(gods) < len(mortals):\n",
" print(\"There are more mortals than gods\")\n",
"else:\n",
" print(\"Same number of gods and mortals\")\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Socrates speaks more than Phaedrus.\n"
]
}
],
"source": [
"#Part 5\n",
"Socrates_qoute = \"\"\"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 [arithmon] and calculation\n",
"[logismon], 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 [tas technas], and he said it\n",
"was necessary to distribute them among the other Egyptians — but Thamus asked\n",
"what the use [ōphelian] 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 [praise\n",
"and blame] about each skill [peri hekastēs technēs] when Theuth was explaining\n",
"them — the account [logos] 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.”\n",
"And Thamus replied, “O most-skilled [technikōtate] Theuth, one person can fashion\n",
"elements of a skill [ta technēs], 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 [invention] 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 [polyēkooi] without instruction, and they will seem to be\n",
"much-learned [polygnōmones] to you, but they will for the most part be unlearned\n",
"[agnōmones], and they will make difficult company, since they will have become\n",
"wise-seemers instead of wise people.\"\"\"\n",
"\n",
"Phaedrus_qoute = \"\"\"You’re talking nonsense — but tell me what you said that you heard. O Socrates, \n",
"you easily make up stories [logous] about Egypt and anywhere you\n",
"want.\"\"\"\n",
"\n",
"#Part 6\n",
"if len(Socrates_qoute) > len(Phaedrus_qoute):\n",
" print(\"Socrates speaks more than Phaedrus.\")\n",
"else:\n",
" print(\"Phaedrus speaks more than Socrates.\")"
]
}
],
"metadata": {
Expand All @@ -374,7 +589,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down