From 5376f6686f6530280c8ff0174640de920f6a6e22 Mon Sep 17 00:00:00 2001 From: connornight7 <157524386+connornight7@users.noreply.github.com> Date: Tue, 6 May 2025 18:27:52 +0000 Subject: [PATCH] done --- 00_variables_strings_numbers.ipynb | 501 ++++++++++++++++++++++++----- 1 file changed, 418 insertions(+), 83 deletions(-) diff --git a/00_variables_strings_numbers.ipynb b/00_variables_strings_numbers.ipynb index 28ecbac..111642f 100644 --- a/00_variables_strings_numbers.ipynb +++ b/00_variables_strings_numbers.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": { "id": "JLTMQ6_2B_b0" }, @@ -30,11 +30,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": { "id": "cZbnXEVXB_b1" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hello world!\n" + ] + } + ], "source": [ "# `print()` is a function\n", "print(greeting)" @@ -42,11 +50,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": { "id": "TOzUs8zPB_b1" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Hello world!'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# What happens when we evaluate this cell?\n", "greeting" @@ -61,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -70,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -88,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -97,16 +116,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'this is a constant'" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "I_SHOULD_NEVER_CHANGE" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -115,9 +145,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "\"uh-oh! don't do this!!!\"" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "I_SHOULD_NEVER_CHANGE" ] @@ -154,9 +195,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'this is a string **literal**'" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# A literal is data that is declared directly -- it is **literally** what it is\n", "\"this is a string **literal**\"" @@ -164,11 +216,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": { "id": "e6_bNdg5B_b3" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "This is a string.\n" + ] + } + ], "source": [ "ex_1 = \"This is a string.\"\n", "print(ex_1)" @@ -176,11 +236,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": { "id": "DEmVQKnLB_b3" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "This is also a string\n" + ] + } + ], "source": [ "ex_2 = 'This is also a string'\n", "print(ex_2)" @@ -188,23 +256,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": { "id": "6N7JobIrB_b3" }, - "outputs": [], - "source": [ - "ex_3 = \"Here is a string.'\n", + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Here is a string.\n" + ] + } + ], + "source": [ + "ex_3 = \"Here is a string.\"\n", "print(ex_3)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": { "id": "pwaxgu1HB_b3" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I asked the question, \"When should I use single quotes.\"\n" + ] + } + ], "source": [ "ex_4 = 'I asked the question, \"When should I use single quotes.\"'\n", "print(ex_4)" @@ -212,11 +296,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": { "id": "1E3MwY0DB_b3" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "edward gibbon\n" + ] + } + ], "source": [ "historian = \"edward gibbon\"\n", "print(historian)" @@ -224,22 +316,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": { "id": "ComprGlSB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Edward Gibbon\n" + ] + } + ], "source": [ "print(historian.title())" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": { "id": "c-GaA4_JB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], "source": [ "# What happens if we forget the parentheses on `title()`?\n", "print(historian.title)" @@ -254,7 +362,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -267,20 +375,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "I'm on multiple lines!\n", + "\n", + "Whoa!\n", + "\n" + ] + } + ], "source": [ "print(multiline_string)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": { "id": "k5K8KbEqB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "becky chambers\n" + ] + } + ], "source": [ "novelist = \"Becky Chambers\"\n", "print(novelist.lower())" @@ -288,29 +416,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "metadata": { "id": "Yo-qC0MwB_b4" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"becky\" == \"becky\"" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": { "id": "QbBcRQZfB_b4" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "\"becky\" == \"Becky\"" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": { "id": "6bJmR4ZSB_b4" }, @@ -322,11 +472,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "metadata": { "id": "ccEVnJY-B_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ada lovelace\n" + ] + } + ], "source": [ "full_name = first_name + \" \" + last_name\n", "print(full_name)" @@ -334,11 +492,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": { "id": "s3ukpffIB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Hello, Ada Lovelace\n" + ] + } + ], "source": [ "greeting = f\" Hello, {first_name} {last_name}\"\n", "print(greeting.title())" @@ -355,44 +521,79 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": { "id": "O4d0bejVB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "tab\n" + ] + } + ], "source": [ "print(\"tab\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 44, "metadata": { "id": "8JguVX8QB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\ttab\n" + ] + } + ], "source": [ "print(\"\\ttab\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": { "id": "9XqoF39uB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Languages: \n", + "Greek\n", + "Latin\n", + "English\n" + ] + } + ], "source": [ "print(\"Languages: \\nGreek\\nLatin\\nEnglish\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "metadata": { "id": "abf-wbFVB_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "string \n" + ] + } + ], "source": [ "str_rspace = \"string \"\n", "print(str_rspace)" @@ -400,22 +601,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": { "id": "B0MQPD2_B_b4" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "string\n" + ] + } + ], "source": [ "print(str_rspace.rstrip())" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 48, "metadata": { "id": "PtN_oFpCB_b5" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "string .\n" + ] + } + ], "source": [ "example = str_rspace + \".\"\n", "print(example)" @@ -423,11 +640,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": { "id": "49wF2WPMB_b5" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "string.\n" + ] + } + ], "source": [ "example_2 = str_rspace.rstrip() + \".\"\n", "print(example_2)" @@ -444,11 +669,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": { "id": "PzEDVoWwB_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "5072" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# integers\n", "238 + 4834" @@ -456,29 +692,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 51, "metadata": { "id": "4J0s8k45B_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "12" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "19 - 7" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": { "id": "hA-9haewB_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "216" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "54 * 4" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 53, "metadata": { "id": "14LxsedTB_b5" }, @@ -489,51 +747,95 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 54, "metadata": { "id": "3mKwnS3gB_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "45" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "num" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 55, "metadata": { "id": "PDogTSWoB_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "50" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "num + 5" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 56, "metadata": { "id": "YUb8QZJLB_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "int" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(num)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": { "id": "YxNBSpHkB_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "3.0" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "30 / 10 # this will return a float" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "metadata": { "id": "QZ3NwuPzB_b5" }, @@ -544,33 +846,66 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 59, "metadata": { "id": "sp-kh3TaB_b5" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4.285714285714286" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "f" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": { "id": "UDRnydXbB_b6" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "float" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "type(f)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": { "id": "LDcm4C4gB_b6" }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "27" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "3 ** 3" ] @@ -581,7 +916,7 @@ "provenance": [] }, "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -595,7 +930,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.7" + "version": "3.12.1" } }, "nbformat": 4,