Skip to content
Open
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
84 changes: 73 additions & 11 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,26 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Anagram\n"
]
}
],
"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",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" for x in word_a:\n",
" if word_a.count(x) != word_b.count(x):\n",
" print(\"Not an Anagram\")\n",
" return False\n",
" print(\"Anagram\")\n",
" return True\n",
"\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
Expand All @@ -72,7 +87,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Not an Anagram\n"
]
}
],
"source": [
"anagram_checker(\"Silent\", \"Night\")"
]
Expand All @@ -81,7 +104,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Anagram\n"
]
}
],
"source": [
"anagram_checker(\"night\", \"Thing\")"
]
Expand All @@ -99,11 +130,26 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Anagram\n"
]
}
],
"source": [
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
"\n",
" if not is_case_sensitive:\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" for x in word_a:\n",
" if word_a.count(x) != word_b.count(x):\n",
" print(\"Not an Anagram\")\n",
" return False\n",
" print(\"Anagram\")\n",
" return True\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\", False) # True"
]
Expand All @@ -112,7 +158,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Not an Anagram\n"
]
}
],
"source": [
"anagram_checker(\"Silent\", \"listen\", True) # False"
]
Expand All @@ -121,7 +175,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Not an Anagram\n"
]
}
],
"source": [
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
Expand All @@ -139,7 +201,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "new-learner",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -153,7 +215,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down