Skip to content

Commit a50fb8c

Browse files
committed
Completed Part 1
1 parent 1e2979e commit a50fb8c

1 file changed

Lines changed: 64 additions & 8 deletions

File tree

‎02_activities/assignments/assignment_1.ipynb‎

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,84 @@
5858
"cell_type": "code",
5959
"execution_count": null,
6060
"metadata": {},
61-
"outputs": [],
61+
"outputs": [
62+
{
63+
"data": {
64+
"text/plain": [
65+
"True"
66+
]
67+
},
68+
"execution_count": 45,
69+
"metadata": {},
70+
"output_type": "execute_result"
71+
}
72+
],
6273
"source": [
74+
"\n",
6375
"# For testing purposes, we will write our code in the function\n",
6476
"def anagram_checker(word_a, word_b):\n",
65-
" # Your code here\n",
77+
" \n",
78+
" ''' Given two valid strings, check if they are anagrams.\n",
79+
" anagram_checker is a boolean comparator: \n",
80+
" True if the two strings are anagrams; False if the two strings are not anagrams.\n",
81+
" Print message to inddicate whether the two strings are anagrams. '''\n",
82+
" \n",
83+
" # Perform an ascending sort of the characters contained in both string arguments\n",
84+
" word1 = 'word_a'\n",
85+
" sorted_word1 = sorted(word1)\n",
86+
" word2 = 'word_b'\n",
87+
" sorted_word2 = sorted(word2)\n",
88+
"\n",
89+
" # Print the two sorted string lists \n",
90+
" print('String one: ', sorted_word1)\n",
91+
" print('String two: ', sorted_word2)\n",
92+
"\n",
93+
" # Perform a boolean comparison and print the result\n",
94+
" if word1 == word2:\n",
95+
" print('The two strings are anagrams of each other')\n",
96+
" else:\n",
97+
" print('The two strings are not anagrams.')\n",
6698
"\n",
6799
"# Run your code to check using the words below:\n",
68100
"anagram_checker(\"Silent\", \"listen\")"
69101
]
70102
},
71103
{
72104
"cell_type": "code",
73-
"execution_count": null,
105+
"execution_count": 46,
74106
"metadata": {},
75-
"outputs": [],
107+
"outputs": [
108+
{
109+
"data": {
110+
"text/plain": [
111+
"False"
112+
]
113+
},
114+
"execution_count": 46,
115+
"metadata": {},
116+
"output_type": "execute_result"
117+
}
118+
],
76119
"source": [
77120
"anagram_checker(\"Silent\", \"Night\")"
78121
]
79122
},
80123
{
81124
"cell_type": "code",
82-
"execution_count": null,
125+
"execution_count": 47,
83126
"metadata": {},
84-
"outputs": [],
127+
"outputs": [
128+
{
129+
"data": {
130+
"text/plain": [
131+
"True"
132+
]
133+
},
134+
"execution_count": 47,
135+
"metadata": {},
136+
"output_type": "execute_result"
137+
}
138+
],
85139
"source": [
86140
"anagram_checker(\"night\", \"Thing\")"
87141
]
@@ -104,6 +158,8 @@
104158
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
105159
" # Modify your existing code here\n",
106160
"\n",
161+
" \n",
162+
"\n",
107163
"# Run your code to check using the words below:\n",
108164
"anagram_checker(\"Silent\", \"listen\", False) # True"
109165
]
@@ -130,7 +186,7 @@
130186
],
131187
"metadata": {
132188
"kernelspec": {
133-
"display_name": "new-learner",
189+
"display_name": "python-env",
134190
"language": "python",
135191
"name": "python3"
136192
},
@@ -144,7 +200,7 @@
144200
"name": "python",
145201
"nbconvert_exporter": "python",
146202
"pygments_lexer": "ipython3",
147-
"version": "3.11.8"
203+
"version": "3.11.13"
148204
}
149205
},
150206
"nbformat": 4,

0 commit comments

Comments
 (0)