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
230 changes: 191 additions & 39 deletions main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -37,19 +37,35 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
"def greater(a,b):\n",
" pass"
" if a > b:\n",
" return a\n",
" else:\n",
" return b\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 55,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.103s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function \n",
"test_greater(greater)"
Expand All @@ -64,19 +80,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 56,
"metadata": {},
"outputs": [],
"source": [
"def greatest(arr):\n",
" great = 0\n",
" for i in arr:\n",
" if i > great:\n",
" great = i\n",
" return great\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 57,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.110s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function \n",
"test_greatest(greatest)"
Expand All @@ -91,19 +124,35 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 58,
"metadata": {},
"outputs": [],
"source": [
"def sum_all(arr):\n",
" valores = 0\n",
" for i in arr:\n",
" valores += i\n",
" return valores\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 59,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.114s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function \n",
"test_sum(sum_all)"
Expand All @@ -118,19 +167,35 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
"def mult_all(arr):\n",
" valores = 1\n",
" for i in arr:\n",
" valores *= i\n",
" return valores\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 86,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.172s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function \n",
"test_mult(mult_all)"
Expand All @@ -145,19 +210,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 84,
"metadata": {},
"outputs": [],
"source": [
"def oper_all(arr, oper):\n",
" if oper == \"+\":\n",
" v_sum = 0\n",
" for s in arr:\n",
" v_sum += s\n",
" return v_sum\n",
" if oper == \"*\":\n",
" v_mult = 1\n",
" for m in arr:\n",
" v_mult *= m\n",
" return v_mult\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 85,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.121s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function \n",
"test_operations(oper_all)"
Expand All @@ -172,19 +261,35 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 100,
"metadata": {},
"outputs": [],
"source": [
"def factorial(n):\n",
" values = 1\n",
" for i in range(1,n+1):\n",
" values *= i\n",
" return values\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 110,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.111s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function \n",
"test_factorial(factorial)"
Expand All @@ -201,19 +306,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 106,
"metadata": {},
"outputs": [],
"source": [
"def unique(arr):\n",
" uni = []\n",
" for i in arr:\n",
" if i not in uni:\n",
" uni += [i]\n",
" return uni\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 114,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.311s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function \n",
"test_unique(unique)"
Expand All @@ -229,27 +351,57 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 127,
"metadata": {},
"outputs": [],
"source": [
"def st_dev(arr):\n",
" pass"
"\n",
" count = 0\n",
" total = 0\n",
"# We can't use any formulas so we need to count the number of values\n",
" for i in arr:\n",
" total +=i\n",
" count +=1\n",
"# Now we can calculate the MEAN\n",
" media = 0\n",
" media = total / count\n",
"\n",
" total_standard_dev = 0\n",
" \n",
" for i in arr:\n",
" total_standard_dev += (i - media)**2\n",
"#Now we have the standard deviation\n",
"\n",
" sta_dev = (total_standard_dev/(count-1))**(1/2)\n",
"\n",
" return sta_dev"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 128,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"....................................................................................................\n",
"----------------------------------------------------------------------\n",
"Ran 100 tests in 0.129s\n",
"\n",
"OK\n"
]
}
],
"source": [
"# This will test your function\n",
"#test_stdev(st_dev)\n",
"test_stdev(st_dev)\n",
"\n",
"# Our tests need to be improved, so for this exercise, we care about the code itself. You may check if you get\n",
"# similar results by checking with:\n",
"\n",
"from statistics import stdev"
"\n"
]
},
{
Expand Down Expand Up @@ -388,7 +540,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
"version": "3.11.4"
},
"toc": {
"base_numbering": 1,
Expand Down