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
100 changes: 83 additions & 17 deletions 02_assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,67 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 39,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 39,
"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",
" small_a = word_a.lower()\n",
" small_b = word_b.lower()\n",
" return sorted(small_a)==sorted(small_b)\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Slient\", \"listen\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 40,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"Slient\", \"Night\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 41,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"anagram_checker(\"night\", \"Thing\")"
]
Expand All @@ -97,24 +132,55 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 98,
"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",
"anagram_checker(\"Slient\", \"listen\", False) # True"
" small_a = word_a.lower()\n",
" small_b = word_b.lower()\n",
" if is_case_sensitive is True and sorted(word_a)==sorted(word_b):\n",
" print(\"True\")\n",
" elif is_case_sensitive is False and sorted(small_a)==sorted(small_b):\n",
" print(\"True\")\n",
" else: print(\"False\")\n",
"anagram_checker(\"Slient\", \"listen\", False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 99,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n"
]
}
],
"source": [
"anagram_checker(\"Slient\", \"Listen\", True) # False"
"\n",
"# Run your code to check using the words below:\n",
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" small_a = word_a.lower()\n",
" small_b = word_b.lower()\n",
" if is_case_sensitive is True and sorted(word_a)==sorted(word_b):\n",
" print(\"True\")\n",
" elif is_case_sensitive is False and sorted(small_a)==sorted(small_b):\n",
" print(\"True\")\n",
" else: print(\"False\")\n",
"anagram_checker(\"Slient\", \"listen\", True)\n",
" # True"
]
},
{
Expand Down Expand Up @@ -144,7 +210,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.9.6"
}
},
"nbformat": 4,
Expand Down
Loading