Skip to content
Closed
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
128 changes: 108 additions & 20 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 `#dc-help`. Our Technical Facilitators and Learning Support staff are here to help you navigate any challenges."
]
Expand All @@ -56,32 +56,73 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 13,
"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",
"\n",
" # change all words to lowercase\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" #sort letters in alphabetical order\n",
" if sorted(word_a) == sorted(word_b):\n",
" return True\n",
" else:\n",
" return False\n",
"# though without the if else statement, it still works.\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"Night\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"night\", \"Thing\")"
]
Expand All @@ -99,29 +140,76 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
"\n",
" # Modify your existing code here\n",
" if is_case_sensitive:\n",
" # sort letters in alphabetical order because case sensitive is true so not change to lowercase\n",
" if sorted(word_a) == sorted(word_b):\n",
" return True\n",
" else:\n",
" return False\n",
" else:\n",
" # change all words to lowercase because case sensitive is false\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" # sort letters in alphabetical order\n",
" if sorted(word_a) == sorted(word_b):\n",
" return True\n",
" else:\n",
" return False\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\", False) # True"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"listen\", True) # False"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
Expand All @@ -139,7 +227,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "new-learner",
"display_name": ".venv (3.14.3)",
"language": "python",
"name": "python3"
},
Expand All @@ -153,7 +241,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.14.3"
}
},
"nbformat": 4,
Expand Down