Skip to content

Commit ec264f4

Browse files
Merge pull request #1 from Chun-YuanChen/assignment-1
UofT-DSI | python - Assignment 1
2 parents 5bbb770 + 27698c4 commit ec264f4

1 file changed

Lines changed: 98 additions & 11 deletions

File tree

02_activities/assignments/assignment_1.ipynb

Lines changed: 98 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,85 @@
5454
"```"
5555
]
5656
},
57+
{
58+
"cell_type": "markdown",
59+
"metadata": {},
60+
"source": [
61+
"### Module: Python\n",
62+
"### Assignment: 1 \n",
63+
"### Name: Chun-Yuan Chen"
64+
]
65+
},
5766
{
5867
"cell_type": "code",
59-
"execution_count": null,
68+
"execution_count": 1,
6069
"metadata": {},
61-
"outputs": [],
70+
"outputs": [
71+
{
72+
"data": {
73+
"text/plain": [
74+
"True"
75+
]
76+
},
77+
"execution_count": 1,
78+
"metadata": {},
79+
"output_type": "execute_result"
80+
}
81+
],
6282
"source": [
6383
"# For testing purposes, we will write our code in the function\n",
6484
"def anagram_checker(word_a, word_b):\n",
6585
" # Your code here\n",
86+
" \n",
87+
" word_a = word_a.replace(\" \", \"\") # CYC: I added this just to remove spaces from words/phrases, even if it is not necessary in this case.\n",
88+
" word_b = word_b.replace(\" \", \"\") # CYC: I added this just to remove spaces from words/phrases, even if it is not necessary in this case.\n",
89+
"\n",
90+
" word_a = word_a.upper()\n",
91+
" word_b = word_b.upper()\n",
92+
" \n",
93+
" return sorted(word_a) == sorted(word_b)\n",
94+
"\n",
6695
"\n",
6796
"# Run your code to check using the words below:\n",
6897
"anagram_checker(\"Silent\", \"listen\")"
6998
]
7099
},
71100
{
72101
"cell_type": "code",
73-
"execution_count": null,
102+
"execution_count": 2,
74103
"metadata": {},
75-
"outputs": [],
104+
"outputs": [
105+
{
106+
"data": {
107+
"text/plain": [
108+
"False"
109+
]
110+
},
111+
"execution_count": 2,
112+
"metadata": {},
113+
"output_type": "execute_result"
114+
}
115+
],
76116
"source": [
77117
"anagram_checker(\"Silent\", \"Night\")"
78118
]
79119
},
80120
{
81121
"cell_type": "code",
82-
"execution_count": null,
122+
"execution_count": 3,
83123
"metadata": {},
84-
"outputs": [],
124+
"outputs": [
125+
{
126+
"data": {
127+
"text/plain": [
128+
"True"
129+
]
130+
},
131+
"execution_count": 3,
132+
"metadata": {},
133+
"output_type": "execute_result"
134+
}
135+
],
85136
"source": [
86137
"anagram_checker(\"night\", \"Thing\")"
87138
]
@@ -99,20 +150,56 @@
99150
"cell_type": "code",
100151
"execution_count": null,
101152
"metadata": {},
102-
"outputs": [],
153+
"outputs": [
154+
{
155+
"data": {
156+
"text/plain": [
157+
"True"
158+
]
159+
},
160+
"execution_count": 4,
161+
"metadata": {},
162+
"output_type": "execute_result"
163+
}
164+
],
103165
"source": [
104166
"def anagram_checker(word_a, word_b, is_case_sensitive):\n",
105167
" # Modify your existing code here\n",
168+
" \n",
169+
" word_a = word_a.replace(\" \", \"\")\n",
170+
" word_b = word_b.replace(\" \", \"\")\n",
171+
" \n",
172+
" if is_case_sensitive == True:\n",
173+
" word_a = word_a # CYC: This line might be a bit redundant in some applications, but I keep it in to make each step clearer for myself.\n",
174+
" word_b = word_b # CYC: This line might be a bit redundant in some applications, but I keep it in to make each step clearer for myself.\n",
175+
" \n",
176+
" else:\n",
177+
" word_a = word_a.upper()\n",
178+
" word_b = word_b.upper()\n",
179+
"\n",
180+
" return sorted(word_a) == sorted(word_b)\n",
181+
"\n",
106182
"\n",
107183
"# Run your code to check using the words below:\n",
108184
"anagram_checker(\"Silent\", \"listen\", False) # True"
109185
]
110186
},
111187
{
112188
"cell_type": "code",
113-
"execution_count": null,
189+
"execution_count": 5,
114190
"metadata": {},
115-
"outputs": [],
191+
"outputs": [
192+
{
193+
"data": {
194+
"text/plain": [
195+
"False"
196+
]
197+
},
198+
"execution_count": 5,
199+
"metadata": {},
200+
"output_type": "execute_result"
201+
}
202+
],
116203
"source": [
117204
"anagram_checker(\"Silent\", \"Listen\", True) # False"
118205
]
@@ -130,7 +217,7 @@
130217
],
131218
"metadata": {
132219
"kernelspec": {
133-
"display_name": "new-learner",
220+
"display_name": "dsi_participant",
134221
"language": "python",
135222
"name": "python3"
136223
},
@@ -144,7 +231,7 @@
144231
"name": "python",
145232
"nbconvert_exporter": "python",
146233
"pygments_lexer": "ipython3",
147-
"version": "3.11.8"
234+
"version": "3.9.19"
148235
}
149236
},
150237
"nbformat": 4,

0 commit comments

Comments
 (0)