From d4cfa007fe4b709bbc4c20252c42a68e13c8a98b Mon Sep 17 00:00:00 2001 From: Tselot Tessema Date: Tue, 13 Oct 2026 22:10:29 -0400 Subject: [PATCH 1/2] https://github.com/tselot-t/python.git --- .../assignments/assignment_1 copy.ipynb | 258 ++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 02_activities/assignments/assignment_1 copy.ipynb diff --git a/02_activities/assignments/assignment_1 copy.ipynb b/02_activities/assignments/assignment_1 copy.ipynb new file mode 100644 index 000000000..d5b57f30c --- /dev/null +++ b/02_activities/assignments/assignment_1 copy.ipynb @@ -0,0 +1,258 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Assignment #1: Anagram Checker\n", + "\n", + "**Background**: Anagram Checker is a program that takes two words and determines if an anagram can be made from it. If so, the program will return `true`, otherwise `false`." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Submission Information\n", + "\n", + "🚨 **Please review our [Assignment Submission Guide](https://github.com/UofT-DSI/onboarding/blob/main/onboarding_documents/submissions.md)** 🚨 for detailed instructions on how to format, branch, and submit your work. Following these guidelines is crucial for your submissions to be evaluated correctly.\n", + "\n", + "### Submission Parameters:\n", + "* Submission Due Date: `11:59 PM - October 13, 2026`\n", + "* The branch name for your repo should be: `assignment-1`\n", + "* What to submit for this assignment:\n", + " * This Jupyter Notebook (assignment_1.ipynb) should be populated and should be the only change in your pull request.\n", + "* What the pull request link should look like for this assignment: `https://github.com//python/pull/`\n", + " * 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", + "\n", + "If you encounter any difficulties or have questions, please don't hesitate to reach out to our team via our Slack at `#dc4-help`. Our Technical Facilitators and Learning Support staff are here to help you navigate any challenges." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Part 1: Building the base Anagram Checker\n", + "\n", + "Given two valid strings, check to see if they are anagrams of each other. If it is, return `True`, else `False`. For this part, we can assume that uppercase letters are the same as if it was a lowercase character.\n", + "\n", + "Examples of anagrams:\n", + "* Silent and Listen\n", + "* Night and Thing\n", + "\n", + "Example outputs:\n", + "```python\n", + "anagram_checker(\"Silent\", \"listen\") # True\n", + "anagram_checker(\"Silent\", \"Night\") # False\n", + "anagram_checker(\"night\", \"Thing\") # True\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'True'" + ] + }, + "execution_count": 73, + "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", + " # criteria for angram: words must have same number of letters and must have the same letters\n", + " #check that length of words match\n", + " if len(word_a)==len(word_b):\n", + " #loop that checks whether each letter in word_a is in word_b\n", + " #not case sensitive to match above outputs for Silent and listen\n", + " #inverted logic using \"not in\" to avoid forcing the computer to check every letter\n", + " for i, letter in enumerate(word_a):\n", + " if letter.upper() not in word_b.upper():\n", + " #test print(True)\n", + " #test print(i,letter)\n", + " return('False') \n", + " return('True')\n", + " #complete top if statement for words that are not the same length\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": 74, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'False'" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"Night\")" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'True'" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"night\", \"Thing\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Part 2: Expanding the functionality of the Anagram Checker\n", + "\n", + "Using your existing and functional anagram checker, let's add a boolean option called `is_case_sensitive`, which will return `True` or `False` based on if the two compared words are anagrams and if we are checking for case sensitivity." + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'True'" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def anagram_checker(word_a, word_b, is_case_sensitive):\n", + " # Modify your existing code here\n", + " if len(word_a)==len(word_b):\n", + " #adding nested if statement for is_case_sensitive parameter\n", + " if is_case_sensitive==True:\n", + " #loop that checks whether each letter in word_a is in word_b\n", + " for i, letter in enumerate(word_a):\n", + " #remove .upper() to compare case of letters\n", + " if letter not in word_b:\n", + " return('False')\n", + " elif is_case_sensitive==False:\n", + " for i, letter in enumerate(word_a):\n", + " #add .upper() to stop comparing case of letters\n", + " if letter.upper() not in word_b.upper():\n", + " return('False') \n", + " return('True')\n", + " else:\n", + " return('False')\n", + " \n", + "\n", + "# Run your code to check using the words below:\n", + "anagram_checker(\"Silent\", \"listen\", False) # True" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'False'" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"listen\", True) # False" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'False'" + ] + }, + "execution_count": 71, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "anagram_checker(\"Silent\", \"Listen\", True) # False" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "|Criteria|Pass|Fail|\n", + "|---|---|---|\n", + "|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.|" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "new-learner", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 0e4352b1834600bbc335216d932b7e94cf350d6f Mon Sep 17 00:00:00 2001 From: Tselot Tessema <104012537+tselot-t@users.noreply.github.com> Date: Tue, 13 Oct 2026 22:35:35 -0400 Subject: [PATCH 2/2] Rename assignment_1 copy.ipynb to assignment_1 .ipynb --- .../assignments/{assignment_1 copy.ipynb => assignment_1 .ipynb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 02_activities/assignments/{assignment_1 copy.ipynb => assignment_1 .ipynb} (100%) diff --git a/02_activities/assignments/assignment_1 copy.ipynb b/02_activities/assignments/assignment_1 .ipynb similarity index 100% rename from 02_activities/assignments/assignment_1 copy.ipynb rename to 02_activities/assignments/assignment_1 .ipynb