Skip to content

Commit 395d21c

Browse files
committed
updated LABs notes
1 parent d83a34e commit 395d21c

6 files changed

Lines changed: 3291 additions & 153 deletions

File tree

LAB/16-play_with_arguments.ipynb

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,15 @@
172172
"id": "8787b1c7-a917-4551-aa70-2ed2abfc44a2",
173173
"metadata": {},
174174
"source": [
175-
"## Arbitrary Parameter"
175+
"## Arbitrary Parameter\n",
176+
"- Arbitrary Positional Arguments (*args): Allows a function to accept any number of non-keyword arguments. These are collected into a tuple.\n",
177+
"- Arbitrary Keyword Arguments (**kwargs): Allows a function to accept any number of named (keyword) arguments. These are collected into a dictionary.\n",
178+
" - (CHECK ARGS-KWARGS NOTEBOOK)"
176179
]
177180
},
178181
{
179182
"cell_type": "code",
180-
"execution_count": 16,
183+
"execution_count": 2,
181184
"id": "d4624912-a100-42f4-b690-e8041b86744c",
182185
"metadata": {},
183186
"outputs": [],
@@ -189,7 +192,7 @@
189192
},
190193
{
191194
"cell_type": "code",
192-
"execution_count": 18,
195+
"execution_count": 3,
193196
"id": "9be3fe55-979e-4673-a58d-3d9a24eaffeb",
194197
"metadata": {},
195198
"outputs": [
@@ -199,7 +202,7 @@
199202
"5.0"
200203
]
201204
},
202-
"execution_count": 18,
205+
"execution_count": 3,
203206
"metadata": {},
204207
"output_type": "execute_result"
205208
}
@@ -210,7 +213,7 @@
210213
},
211214
{
212215
"cell_type": "code",
213-
"execution_count": 19,
216+
"execution_count": 4,
214217
"id": "c0d1367e-ecb3-4d6f-93d7-68c027cb558f",
215218
"metadata": {},
216219
"outputs": [
@@ -220,7 +223,7 @@
220223
"4.666666666666667"
221224
]
222225
},
223-
"execution_count": 19,
226+
"execution_count": 4,
224227
"metadata": {},
225228
"output_type": "execute_result"
226229
}
@@ -229,6 +232,29 @@
229232
"average(2, 5, 7)"
230233
]
231234
},
235+
{
236+
"cell_type": "code",
237+
"execution_count": 7,
238+
"id": "c8c52764-7c57-4b84-80ac-f9335a84025b",
239+
"metadata": {},
240+
"outputs": [
241+
{
242+
"data": {
243+
"text/plain": [
244+
"5.0"
245+
]
246+
},
247+
"execution_count": 7,
248+
"metadata": {},
249+
"output_type": "execute_result"
250+
}
251+
],
252+
"source": [
253+
"# We can pass the iterable object and unpack those with * in a function\n",
254+
"my_list = [1, 4, 7, 9, 4]\n",
255+
"average(*my_list) # here, * will unpack each element from my_list and pass those as arbitrary argument to function"
256+
]
257+
},
232258
{
233259
"cell_type": "markdown",
234260
"id": "c2b168e4-e79e-44c3-90b2-16da178cd349",

0 commit comments

Comments
 (0)