Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 89 additions & 15 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Submission Information\n",
"## Submission Information - Submitted by Mohammed Hashim Siddiqui\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",
Expand All @@ -40,7 +40,7 @@
"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",
"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",
Expand All @@ -56,32 +56,74 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 12,
"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",
" # Remove spaces from both words\n",
" word_a = word_a.replace(\" \", \"\")\n",
" word_b = word_b.replace(\" \", \"\")\n",
"\n",
" # Convert both words to lowercase for case-insensitive comparison\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
"\n",
" # Check if sorted characters of both words are the same\n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"Night\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"night\", \"Thing\")"
]
Expand All @@ -97,12 +139,33 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
" # Remove spaces from both words\n",
" word_a = word_a.replace(\" \", \"\")\n",
" word_b = word_b.replace(\" \", \"\")\n",
"\n",
" # Check case sensitivity\n",
" if not is_case_sensitive:\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
"\n",
" # Check if sorted characters of both words are the same\n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\", False) # True"
Expand All @@ -112,7 +175,18 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
Expand All @@ -130,7 +204,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "new-learner",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -144,7 +218,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.12.9"
}
},
"nbformat": 4,
Expand Down
152 changes: 152 additions & 0 deletions assignment_1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"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 - May 4, 2025`\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/<your_github_username>/python/pull/<pr_id>`\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 `#dc-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 Think\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": null,
"metadata": {},
"outputs": [],
"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",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anagram_checker(\"Silent\", \"Night\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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": null,
"metadata": {},
"outputs": [],
"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",
"anagram_checker(\"Silent\", \"listen\", False) # True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}