From f26b289d4d2a392d80abe4781b88b3161d76f2fc Mon Sep 17 00:00:00 2001 From: jrleung Date: Sun, 4 May 2025 15:30:32 -0400 Subject: [PATCH 1/2] Completed assignment 1 for Python --- 02_activities/assignments/assignment_1.ipynb | 95 +++++++++++++++++--- 1 file changed, 81 insertions(+), 14 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index bd82b6b8b..5d5560f88 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,13 +56,27 @@ }, { "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", + " if sorted(word_b.lower()) == sorted(word_a.lower()):\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 +84,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 +133,32 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'True'" + ] + }, + "execution_count": 4, + "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_b) == sorted(word_a):\n", + " return \"True\"\n", + " else:\n", + " return \"False\"\n", + " else:\n", + " if sorted(word_b.lower()) == sorted(word_a.lower()):\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,9 +166,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'False'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -130,7 +197,7 @@ ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": "dsi_participant", "language": "python", "name": "python3" }, @@ -144,7 +211,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.9.15" } }, "nbformat": 4, From 9b13f6d7e7ef13ffe8ab8225de2947fca65a1090 Mon Sep 17 00:00:00 2001 From: jrleung Date: Mon, 5 May 2025 22:39:12 -0400 Subject: [PATCH 2/2] Updating Python assignment 1 after feedback --- 02_activities/assignments/assignment_1.ipynb | 45 ++++++++------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index 5d5560f88..9999c3e80 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -56,16 +56,16 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'True'" + "True" ] }, - "execution_count": 1, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -73,10 +73,7 @@ "source": [ "# For testing purposes, we will write our code in the function\n", "def anagram_checker(word_a, word_b):\n", - " if sorted(word_b.lower()) == sorted(word_a.lower()):\n", - " return \"True\"\n", - " else:\n", - " return \"False\"\n", + " return sorted(word_b.lower()) == sorted(word_a.lower())\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" @@ -84,16 +81,16 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'False'" + "False" ] }, - "execution_count": 2, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -104,16 +101,16 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'True'" + "True" ] }, - "execution_count": 3, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -133,16 +130,16 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'True'" + "True" ] }, - "execution_count": 4, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -150,15 +147,9 @@ "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", " if is_case_sensitive:\n", - " if sorted(word_b) == sorted(word_a):\n", - " return \"True\"\n", - " else:\n", - " return \"False\"\n", + " return sorted(word_b) == sorted(word_a)\n", " else:\n", - " if sorted(word_b.lower()) == sorted(word_a.lower()):\n", - " return \"True\"\n", - " else:\n", - " return \"False\"\n", + " return sorted(word_b.lower()) == sorted(word_a.lower())\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\", False) # True" @@ -166,16 +157,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'False'" + "False" ] }, - "execution_count": 5, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" }