Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dddddd in line 8 #51

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
329 changes: 260 additions & 69 deletions module-1/lab-advanced-regex/your-code/main.ipynb

Large diffs are not rendered by default.

260 changes: 188 additions & 72 deletions module-1/lab-error-handling/your-code/main.ipynb

Large diffs are not rendered by default.

393 changes: 359 additions & 34 deletions module-1/lab-functional-programming/your-code/main.ipynb

Large diffs are not rendered by default.

253 changes: 191 additions & 62 deletions module-1/lab-lambda-functions/your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n"
]
}
],
"source": [
"l = [######]\n",
"f = lambda x: #define the lambda expression\n",
"import random\n",
"l = [i for i in range(10)] \n",
"f = lambda x: x + 2\n",
"b = []\n",
"def modify_list(lst, fudduLambda):\n",
" for x in ####:\n",
" b.append(#####(x))\n",
"#Call modify_list(##,##)\n",
"#print b"
"def modify_list(l, f):\n",
" for x in l:\n",
" b.append(f(x))\n",
" #Call modify_list(##,##)\n",
"modify_list(l,f)\n",
"print(b)"
]
},
{
Expand All @@ -59,12 +69,24 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 43,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"273.15"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here:\n",
"\n"
"Cel_to_Kel = lambda x:x + 273.15\n",
"# Cel_to_Kel(0)"
]
},
{
Expand All @@ -76,13 +98,25 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 44,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[285.15, 296.15, 311.15, 218.14999999999998, 297.15]\n"
]
}
],
"source": [
"temps = [12, 23, 38, -55, 24]\n",
"\n",
"# Your code here:"
"Kel = []\n",
"for x in temps:\n",
" Kel.append(Cel_to_Kel(x))\n",
"print(Kel)\n",
"# Your code here:\n",
"#comprehension: converted = [Cel_to_Kel(x) for x in temps]"
]
},
{
Expand All @@ -96,11 +130,12 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 46,
"metadata": {},
"outputs": [],
"source": [
"# Your code here:\n"
"# Your code here:\n",
"mod = lambda x, y: 1 if x % y == 0 or y % x == 0 else 0\n"
]
},
{
Expand All @@ -114,17 +149,31 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 47,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def divisor(b):\n",
" \"\"\"\n",
" input: a number\n",
" output: a function that returns 1 if the number is divisible by another number (to be passed later) and zero otherwise\n",
" \"\"\"\n",
" return mod(5,b)\n",
"# divisor(1)\n",
"# input: a number\n",
"# output: a function that returns 1 if the number is divisible by another number (to be passed later) and zero otherwise\n",
"# \"\"\"\n",
" \n",
" # Your code here:\n",
" \n",
" # Your code here:"
"#return lamdba later_arg: mod(b, later_arg)"
]
},
{
Expand All @@ -136,11 +185,25 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 57,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here:\n"
"# Your code here:\n",
"def divisible5(i):\n",
" return mod(5,i)\n",
"divisible5(5)"
]
},
{
Expand All @@ -152,18 +215,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 55,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"divisible5(10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 58,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"divisible5(8)"
]
Expand Down Expand Up @@ -218,14 +303,27 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 61,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[(1, 2), (2, 3), (3, 4), (4, 5)]"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list1 = [1,2,3,4]\n",
"list2 = [2,3,4,5]\n",
"## Zip the lists together \n",
"## Print the zipped list "
"zippedA = zip(list1, list2)\n",
"## Print the zipped list \n",
"list(zippedA)"
]
},
{
Expand All @@ -237,28 +335,32 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 77,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\n\\ncompare = lambda ###: print(\"True\") if ### else print(\"False\")\\nfor ### in zip(list1,list2):\\n compare(###)\\n \\n'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"False\n",
"False\n",
"False\n",
"False\n"
]
}
],
"source": [
"'''\n",
"# '''\n",
"\n",
"compare = lambda ###: print(\"True\") if ### else print(\"False\")\n",
"for ### in zip(list1,list2):\n",
" compare(###)\n",
"# compare = lambda ###: print(\"True\") if ### else print(\"False\")\n",
"# for ### in zip(list1,list2):\n",
"# compare(###)\n",
" \n",
"''' "
"# ''' \n",
"\n",
"compare = lambda x,y: print(\"True\") if x > y else print(\"False\")\n",
"for x,y in zip(list1,list2):\n",
" compare(x,y)"
]
},
{
Expand All @@ -274,14 +376,33 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 50,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[('Political Science', 'Essay'),\n",
" ('Computer Science', 'Homework'),\n",
" ('Engineering', 'Lab'),\n",
" ('Mathematics', 'Module')]"
]
},
"execution_count": 50,
"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",
"zippedB = list(zip(list1, list2)) \n",
"# zippedB\n",
"zipSorted = sorted(zippedB, key = lambda x: x[1])\n",
"zipSorted\n",
" "
]
},
{
Expand All @@ -295,21 +416,29 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 45,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"[('Toyota', 1995), ('Honda', 1997), ('Audi', 2001), ('BMW', 2005)]"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d = {'Honda': 1997, 'Toyota': 1995, 'Audi': 2001, 'BMW': 2005}\n",
"\n",
"# Your code here:"
"# Your code here:\n",
"dList = [(k, v) for (k, v) in d.items()]\n",
"# dList\n",
"dSorted = sorted(dList, key = lambda x: x[1])\n",
"dSorted"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading