From 98f6dea8724f21240d61c72aa413ef9cf3b1882c Mon Sep 17 00:00:00 2001 From: CarlaKulcsar Date: Sun, 15 Mar 2026 19:53:25 -0400 Subject: [PATCH] file completed --- 02_activities/assignments/assignment_1.ipynb | 117 ++++++++++++++++--- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 2dca19d0b..ba53e26ac 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,13 +56,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# For testing purposes, we will write our code in the function\n", "def anagram_checker(word_a, word_b):\n", - " # Your code here\n", + " # for case insensitive comparioson use .casefold()\n", + " word_a_case = word_a.casefold()\n", + " word_b_case = word_b.casefold()\n", + "\n", + " # if/else statement for if anagram or not: sort letters alphabetically using sorted(), if it is an anagram the strings are now exactly the same (==)\n", + " if sorted(word_a_case) == sorted(word_b_case):\n", + " return True\n", + " else:\n", + " return False\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" @@ -70,18 +89,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Night\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"night\", \"Thing\")" ] @@ -97,12 +138,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", " # Modify your existing code here\n", + " if is_case_sensitive:\n", + " if sorted(word_a) == sorted(word_b):\n", + " return True\n", + " else:\n", + " return False\n", + "\n", + " else:\n", + " word_a_case = word_a.casefold()\n", + " word_b_case = word_b.casefold()\n", + " if sorted(word_a_case) == sorted(word_b_case):\n", + " return True\n", + " else:\n", + " return False\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -110,18 +175,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"listen\", True) # False" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -139,7 +226,7 @@ ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": "base", "language": "python", "name": "python3" }, @@ -153,7 +240,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.13.5" } }, "nbformat": 4,