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
267 changes: 227 additions & 40 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:23.403284Z",
"start_time": "2021-03-24T17:08:23.393500Z"
}
},
"outputs": [],
"source": [
"def modify_list(lst, lmbda):\n",
Expand All @@ -31,7 +36,8 @@
" Output: the transformed list\n",
" \"\"\"\n",
" \n",
" # your code here\n",
" result = list(map(lmbda,lst))\n",
" return result\n",
" "
]
},
Expand All @@ -46,11 +52,16 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:24.480168Z",
"start_time": "2021-03-24T17:08:24.471725Z"
}
},
"outputs": [],
"source": [
"# your code here"
"lam = lambda a: 273.15 + a"
]
},
{
Expand All @@ -62,13 +73,31 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:25.405547Z",
"start_time": "2021-03-24T17:08:25.378125Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[285.15, 296.15, 311.15, 218.14999999999998, 297.15]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temps = [12, 23, 38, -55, 24]\n",
"\n",
"# your code here"
"# your code here\n",
"\n",
"modify_list(temps,lam)"
]
},
{
Expand All @@ -82,11 +111,18 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:26.348401Z",
"start_time": "2021-03-24T17:08:26.340118Z"
}
},
"outputs": [],
"source": [
"# your code here"
"# your code here\n",
"\n",
"mod = lambda x,y: 1 if (x%y == 0) else 0"
]
},
{
Expand All @@ -100,8 +136,13 @@
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:27.121096Z",
"start_time": "2021-03-24T17:08:27.116591Z"
}
},
"outputs": [],
"source": [
"def divisor(b):\n",
Expand All @@ -111,7 +152,9 @@
" divisible by another number (to be passed later) and zero otherwise.\n",
" \"\"\"\n",
" \n",
" # your code here"
" # your code here\n",
" \n",
" return lambda y: 1 if (y%b == 0) else 0"
]
},
{
Expand All @@ -123,11 +166,17 @@
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"execution_count": 6,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:27.898771Z",
"start_time": "2021-03-24T17:08:27.889866Z"
}
},
"outputs": [],
"source": [
"# your code here"
"# your code here\n",
"divisible5 = divisor(5)"
]
},
{
Expand All @@ -139,18 +188,50 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 7,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:28.631631Z",
"start_time": "2021-03-24T17:08:28.622940Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"divisible5(10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:28.969713Z",
"start_time": "2021-03-24T17:08:28.960979Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"divisible5(8)"
]
Expand All @@ -168,16 +249,21 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"execution_count": 9,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:29.674529Z",
"start_time": "2021-03-24T17:08:29.664318Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[(1,), (2,), (3,), (4,), (5,)]"
]
},
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -199,14 +285,34 @@
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"execution_count": 10,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:30.566525Z",
"start_time": "2021-03-24T17:08:30.547540Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[('Green', 'eggs'),\n",
" ('cheese', 'cheese'),\n",
" ('English', 'cucumber'),\n",
" ('tomato', 'tomato')]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list1 = ['Green', 'cheese', 'English', 'tomato']\n",
"list2 = ['eggs', 'cheese', 'cucumber', 'tomato']\n",
"\n",
"# your code here"
"# your code here\n",
"[x for x in zip(list1,list2)]"
]
},
{
Expand All @@ -222,14 +328,31 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"execution_count": 11,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:33.910475Z",
"start_time": "2021-03-24T17:08:33.901366Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('Engineering', 'Lab'), ('Computer Science', 'Homework'), ('Mathematics', 'Module'), ('Political Science', 'Essay')]\n"
]
}
],
"source": [
"list1 = ['Engineering', 'Computer Science', 'Political Science', 'Mathematics']\n",
"list2 = ['Lab', 'Homework', 'Essay', 'Module']\n",
"\n",
"# your code here"
"# your code here\n",
"list3 = [x for x in zip(list1,list2)]\n",
"lam = lambda lst: lst[1][1]\n",
"list3.sort(key=lam)\n",
"print(list3)"
]
},
{
Expand All @@ -243,13 +366,30 @@
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"execution_count": 12,
"metadata": {
"ExecuteTime": {
"end_time": "2021-03-24T17:08:34.920152Z",
"start_time": "2021-03-24T17:08:34.912064Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('Toyota', 1995), ('Honda', 1997), ('Audi', 2001), ('BMW', 2005)]\n"
]
}
],
"source": [
"d = {'Honda': 1997, 'Toyota': 1995, 'Audi': 2001, 'BMW': 2005}\n",
"\n",
"# your code here"
"# your code here\n",
"list3 = [x for x in zip(d.keys(),d.values())]\n",
"lam = lambda lst: lst[1]\n",
"list3.sort(key=lam)\n",
"print(list3)"
]
}
],
Expand All @@ -269,7 +409,54 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.8.2"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": 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": true
}
},
"nbformat": 4,
Expand Down