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
23 changes: 19 additions & 4 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@
"outputs": [],
"source": [
"# For testing purposes, we will write our code in the function\n",
"# This function is defined to test whether two arguments are anagrams or not\n",
"def anagram_checker(word_a, word_b):\n",
" # Your code here\n",
"\n",
" # creates two lists of sorted letters from word_a and word_b and converts them to lower case letters in order to test if they are equal\n",
" \n",
" word_a = sorted(word_a.lower())\n",
" word_b = sorted(word_b.lower())\n",
" \n",
" return word_a == word_b\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\")"
]
Expand Down Expand Up @@ -101,9 +107,18 @@
"metadata": {},
"outputs": [],
"source": [
"# This function is defined to test whether two arguments are anagrams or not and case_Sensitivity if specified\n",
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # Modify your existing code here\n",
"\n",
" \n",
" if is_case_sensitive == True:\n",
" word_a = sorted(word_a)\n",
" word_b = sorted(word_b)\n",
" else: \n",
" word_a = sorted(word_a.lower())\n",
" word_b = sorted(word_b.lower())\n",
" \n",
" return word_a == word_b\n",
"# Run your code to check using the words below:\n",
"anagram_checker(\"Silent\", \"listen\", False) # True"
]
Expand Down Expand Up @@ -139,7 +154,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "new-learner",
"display_name": "python-env (3.11.18)",
"language": "python",
"name": "python3"
},
Expand All @@ -153,7 +168,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.18"
}
},
"nbformat": 4,
Expand Down