From 0d5323ee5abacf5205f1e643baa4723417ed6ba5 Mon Sep 17 00:00:00 2001 From: smittrivedi Date: Wed, 26 Nov 2025 22:22:56 -0500 Subject: [PATCH 1/2] Anagram Checker Assignment --- 02_activities/assignments/assignment_1.ipynb | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 625be024..d6003f26 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -63,6 +63,12 @@ "# For testing purposes, we will write our code in the function\n", "def anagram_checker(word_a, word_b):\n", " # Your code here\n", + " first_word = word_a.lower()\n", + " second_word = word_b.lower()\n", + " if sorted(first_word) == sorted(second_word): # sorted() rearranges the letters of each word in alphabetical order. so here we can check after sorting it if both are equal to see if they are anagram\n", + " print(\"this is anagram\")\n", + " else:\n", + " print(\"this is not anagram\") \n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" @@ -101,8 +107,14 @@ "metadata": {}, "outputs": [], "source": [ - "def anagram_checker(word_a, word_b, is_case_sensitive):\n", + "def anagram_checker(word_a, word_b, is_case_sensitive): # is_case_sensitive parameter is used to control make sure there is no case difference when set to falwse snd there is case difference when set to true\n", " # Modify your existing code here\n", + " first_word = word_a.lower()\n", + " second_word = word_b.lower()\n", + " if sorted(first_word) == sorted(second_word):\n", + " print(\"this is anagram\")\n", + " else:\n", + " print(\"this is not anagram\") \n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -126,6 +138,13 @@ "|Code Execution|All code cells execute without errors.|Any code cell produces an error upon execution.|\n", "|Code Quality|Code is well-organized, concise, and includes necessary comments for clarity. E.g. Great use of variable names.|Code is unorganized, verbose, or lacks necessary comments. E.g. Single character variable names outside of loops.|" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From a006418fb196bb663cb7cc6a9faec290a4570ae6 Mon Sep 17 00:00:00 2001 From: Smit Trivedi Date: Wed, 3 Dec 2025 21:35:11 -0500 Subject: [PATCH 2/2] Updated assignment Part 1 and Part 2 --- 02_activities/assignments/assignment_1.ipynb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index d6003f26..7931e056 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -67,8 +67,10 @@ " second_word = word_b.lower()\n", " if sorted(first_word) == sorted(second_word): # sorted() rearranges the letters of each word in alphabetical order. so here we can check after sorting it if both are equal to see if they are anagram\n", " print(\"this is anagram\")\n", + " return True\n", " else:\n", - " print(\"this is not anagram\") \n", + " print(\"this is not anagram\")\n", + " return False \n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" @@ -109,13 +111,12 @@ "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive): # is_case_sensitive parameter is used to control make sure there is no case difference when set to falwse snd there is case difference when set to true\n", " # Modify your existing code here\n", - " first_word = word_a.lower()\n", - " second_word = word_b.lower()\n", - " if sorted(first_word) == sorted(second_word):\n", - " print(\"this is anagram\")\n", - " else:\n", - " print(\"this is not anagram\") \n", + " \n", + " if not is_case_sensitive:\n", + " word_a = word_a.lower()\n", + " word_b = word_b.lower()\n", "\n", + " return sorted(word_a) == sorted(word_b)\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" ]