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
148 changes: 128 additions & 20 deletions your-code/main.ipynb → your-code/Lambda Lab.ipynb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,28 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[1, 4, 9, 16, 25]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def modify_list(lst, lmbda):\n",
" \"\"\"\n",
" Input: list and lambda expression\n",
" Output: the transformed list\n",
" \"\"\"\n",
" \n",
" # your code here\n",
" "
"ls = [1, 2, 3, 4, 5]\n",
"\n",
"list(map(lambda x: x**2, ls))\n",
"\n"
]
},
{
Expand All @@ -46,11 +58,23 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"<function __main__.<lambda>(x)>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here"
"# your code here\n",
"lambda x: x + 273.15"
]
},
{
Expand All @@ -62,13 +86,27 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"execution_count": 6,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"[285.15, 296.15, 311.15, 218.14999999999998, 297.15]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temps = [12, 23, 38, -55, 24]\n",
"\n",
"# your code here"
"# your code here\n",
"list(map(lambda x: x + 273.15, temps))"
]
},
{
Expand All @@ -82,11 +120,12 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"# your code here\n",
"mod = lambda x, y: 1 if x%y == 0 else 0 "
]
},
{
Expand All @@ -100,9 +139,20 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 18,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"<function __main__.divisor.<locals>.<lambda>(x, y)>"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def divisor(b):\n",
" \"\"\"\n",
Expand All @@ -111,7 +161,11 @@
" divisible by another number (to be passed later) and zero otherwise.\n",
" \"\"\"\n",
" \n",
" # your code here"
" # your code here\n",
" mod = lambda x, y: 1 if x%y == 0 else 0\n",
" return mod\n",
"\n",
"divisor(5)"
]
},
{
Expand All @@ -123,11 +177,23 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 17,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"<function __main__.divisor.<locals>.<lambda>(x, y)>"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here"
"# your code here\n",
"divisor(5)"
]
},
{
Expand Down Expand Up @@ -269,7 +335,49 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.8.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
Expand Down