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
140 changes: 121 additions & 19 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,46 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# your code here\n"
"modify_list = [2, 7, 6, 4, 1, 2, 9, 11, 5, 3]\n",
"\n",
"\n",
"\n",
"def my_funct(list, lamfunc):\n",
" empty_list = []\n",
" for element in list:\n",
" x = (lamfunc)(element)\n",
" empty_list.append(x)\n",
" return empty_list\n",
"\n",
"\n",
"\n",
"## (lambda x : x**2)(4)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[4, 9, 8, 6, 3, 4, 11, 13, 7, 5]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"lamfunc = (lambda x : x + 2)\n",
"\n",
"my_funct(modify_list, lamfunc)"
]
},
{
Expand All @@ -54,9 +89,29 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Temperature in Kelvin ( K ) = 273.15\n"
]
}
],
"source": [
"# Your code here:\n"
"# from degree Celsius to Kelvin\n",
"def Celsius_to_Kelvin(C):\n",
" return (C + 273.15)\n",
" \n",
"# Driver Code\n",
" \n",
"# variable to hold the\n",
"# temperature in Celsius\n",
"C = 0\n",
" \n",
"print(\"Temperature in Kelvin ( K ) = \",\n",
" Celsius_to_Kelvin(C))\n",
"\n"
]
},
{
Expand All @@ -70,11 +125,27 @@
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[285.15, 296.15, 311.15, 218.14999999999998, 297.15]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"temps = [12, 23, 38, -55, 24]\n",
"\n",
"# Your code here:\n"
"\n",
"\n",
"lamfunc = (lambda temps : temps + 273.15)\n",
"\n",
"my_funct(temps, lamfunc)\n",
"\n"
]
},
{
Expand All @@ -88,7 +159,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -106,7 +177,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -127,7 +198,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -174,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -209,17 +280,32 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list1 = [1,2,4,4]\n",
"list2 = [2,3,3,5]\n",
"## Zip the lists together \n",
"\n",
"zipped = zip(list1,list2)\n",
"list(zipped)\n",
"\n",
"## Print the zipped list \n",
"\n",
"## Use a lambda expression to compare if: list1 element > list2 element\n"
"## Use a lambda expression to compare if: list1 element > list2 element\n",
"## list1 (element) > list2 (element)\n",
"list1 > list2"
]
},
{
Expand All @@ -242,14 +328,30 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[('Engineering', 'Lab'),\n",
" ('Computer Science', 'Homework'),\n",
" ('Political Science', 'Essay'),\n",
" ('Mathematics', 'Module')]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list1 = ['Engineering', 'Computer Science', 'Political Science', 'Mathematics']\n",
"list2 = ['Lab', 'Homework', 'Essay', 'Module']\n",
"\n",
"# Your code here:\n"
"# Your code here:\n",
"zipped = zip(list1,list2)\n",
"list(zipped)"
]
},
{
Expand All @@ -263,7 +365,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -296,7 +398,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down