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
122 changes: 70 additions & 52 deletions 02_activities/assignments/assignment_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,28 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"true\n"
"True\n"
]
}
],
"source": [
"def anagram_checker (silent,listen):\n",
" silent = sorted(silent)\n",
" listen = sorted(listen)\n",
"def anagram_checker(word_a, word_b):\n",
" # Normalize by converting both words to lowercase\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" \n",
" # Check if sorted characters of both words are equal\n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"if sorted('silent') == sorted('listen'):\n",
" print('true')"
"# Run your code to check using the words below:\n",
"print(anagram_checker(\"Silent\", \"listen\")) \n"
]
},
{
Expand All @@ -103,25 +107,28 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"false\n"
"False\n"
]
}
],
"source": [
"def anagram_checker (Silent,Night):\n",
" Silent == sorted(Silent)\n",
" Night == sorted(Night)\n",
"def anagram_checker(word_a, word_b):\n",
" # Normalize by converting both words to lowercase\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" \n",
" # Check if sorted characters of both words are equal\n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"if sorted(\"Silent\") == (\"Night\"):\n",
" print('true')\n",
"else: print('false')"
"# Run your code to check using the words below:\n",
"print(anagram_checker(\"Silent\", \"Night\")) \n"
]
},
{
Expand All @@ -135,25 +142,28 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"false\n"
"True\n"
]
}
],
"source": [
"def anagram_checker (night,thing):\n",
" night == sorted(night).lower\n",
" Thing == sorted(Thing).lower\n",
"if sorted('night') == ('Thing'):\n",
" print('true')\n",
"else:\n",
" print('false')"
"def anagram_checker(word_a, word_b):\n",
" # Normalize by converting both words to lowercase\n",
" word_a = word_a.lower()\n",
" word_b = word_b.lower()\n",
" \n",
" # Check if sorted characters of both words are equal\n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"# Run your code to check using the words below:\n",
"print(anagram_checker(\"night\", \"Thing\")) \n"
]
},
{
Expand All @@ -180,57 +190,65 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"false\n"
"True\n"
]
}
],
"source": [
"def anagram_checker (Silent, listen, is_case_sensitive):\n",
" Silent == (Silent).lower\n",
" listen == (listen).lower\n",
"if sorted('Silent') == sorted('listen'):\n",
" print('true')\n",
"else:\n",
" print('false')"
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # If case sensitivity is not required, convert both words to lowercase\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 equal\n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"# Run your code to check using the words below:\n",
"print(anagram_checker(\"Silent\", \"listen\", False)) \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"anagram_checker(\"Silent\", \"Listen\", True) # False"
]
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"false\n"
"False\n"
]
}
],
"source": [
"def anagram_checker (Silent, Listen, is_case_sensitive):\n",
" Silent == (Silent).lower\n",
" Listen == (Listen).lower\n",
"if sorted('Silent') == sorted('Listen'):\n",
" print('true')\n",
"else:\n",
" print('false')"
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
" # If case sensitivity is not required, convert both words to lowercase\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 equal\n",
" return sorted(word_a) == sorted(word_b)\n",
"\n",
"# Run your code to check using the words below:\n",
"print(anagram_checker(\"Silent\", \"Listen\", True)) \n"
]
},
{
Expand Down Expand Up @@ -260,7 +278,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
"version": "3.9.15"
}
},
"nbformat": 4,
Expand Down