diff --git a/02_activities/assignments/assignment_1.ipynb b/02_activities/assignments/assignment_1.ipynb index f9a68ad9b..b1d881287 100644 --- a/02_activities/assignments/assignment_1.ipynb +++ b/02_activities/assignments/assignment_1.ipynb @@ -26,10 +26,10 @@ " * Open a private window in your browser. Copy and paste the link to your pull request into the address bar. Make sure you can see your pull request properly. This helps the technical facilitator and learning support staff review your submission easily.\n", "\n", "Checklist:\n", - "- [ ] Created a branch with the correct naming convention.\n", - "- [ ] Ensured that the repository is public.\n", - "- [ ] Reviewed the PR description guidelines and adhered to them.\n", - "- [ ] Verify that the link is accessible in a private browser window.\n", + "- [x] Created a branch with the correct naming convention.\n", + "- [x] Ensured that the repository is public.\n", + "- [x] Reviewed the PR description guidelines and adhered to them.\n", + "- [x] Verify that the link is accessible in a private browser window.\n", "\n", "If you encounter any difficulties or have questions, please don't hesitate to reach out to our team via our Slack at `#cohort-3-help`. Our Technical Facilitators and Learning Support staff are here to help you navigate any challenges." ] @@ -56,32 +56,76 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# This is a function, which we will learn more about next week. For testing purposes, we will write our code in the function\n", "def anagram_checker(word_a, word_b):\n", " # Your code here\n", "\n", + " word_a = word_a.lower() # this part of the function uses the .lower method to make all letters in each string lowercase\n", + " word_b = word_b.lower()\n", + "\n", + " word_a = sorted(word_a) # this part of the function uses the sorted function to return an alphabetical list of the letters in both variables\n", + " word_b = sorted(word_b)\n", + "\n", + " if word_a == word_b: \n", + " return True\n", + " else: \n", + " return False\n", + " \n", "# Run your code to check using the words below:\n", "anagram_checker(\"Silent\", \"listen\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"Silent\", \"Night\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "anagram_checker(\"night\", \"Thing\")" ] @@ -97,24 +141,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True False\n" + ] + } + ], "source": [ "def anagram_checker(word_a, word_b, is_case_sensitive):\n", " # Modify your existing code here\n", "\n", + " if is_case_sensitive is False: \n", + " word_a = word_a.lower() # this part of the function uses the .lower method to make all letters in each string lowercase\n", + " word_b = word_b.lower()\n", + " \n", + " word_a = sorted(word_a) # this part of the function uses the sorted function to return an alphabetical list of the letters in both variables\n", + " word_b = sorted(word_b)\n", + "\n", + " if word_a == word_b: \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" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "anagram_checker(\"Silent\", \"Listen\", True) # False" + "print(anagram_checker(\"Silent\", \"listen\", False), anagram_checker(\"Silent\", \"listen\", True))\n" ] }, { @@ -144,7 +199,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.9.18" } }, "nbformat": 4,