diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index bee48d5a0..f4f29cc31 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": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], "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", + " word_a = word_a.lower()\n", + " word_b = word_b.lower()\n", + " \n", + " if sorted(word_a) == sorted(word_b):\n", + " print(True)\n", + " else:\n", + " print(False)\n", "\n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" @@ -70,18 +84,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], "source": [ "anagram_checker(\"Silent\", \"Night\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], "source": [ "anagram_checker(\"night\", \"Thing\")" ] @@ -97,22 +127,48 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", " # Modify your existing code here\n", "\n", - "# Run your code to check using the words below:\n", + " if not is_case_sensitive:\n", + " word_a = word_a.lower()\n", + " word_b = word_b.lower()\n", + "\n", + " # Compare sorted letters and print result\n", + " if sorted(word_a) == sorted(word_b):\n", + " print(True)\n", + " else:\n", + " print(False)\n", + "\n", + "\n", "anagram_checker(\"Silent\", \"listen\", False) # True" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n" + ] + } + ], "source": [ "anagram_checker(\"Silent\", \"Listen\", True) # False" ] @@ -130,7 +186,7 @@ ], "metadata": { "kernelspec": { - "display_name": "new-learner", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -144,7 +200,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.13.5" } }, "nbformat": 4,