Commit 7cb62627 authored by christian.foerster's avatar christian.foerster

minor changes

parent 73d053b5
...@@ -440,7 +440,7 @@ ...@@ -440,7 +440,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"### Tupel" "### Tuple"
] ]
}, },
{ {
...@@ -945,36 +945,19 @@ ...@@ -945,36 +945,19 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# you can even pass functions as function arguments\n",
"def add_ten(func,a,b):\n",
" '''\n",
" my function\n",
" '''\n",
" return func(a,b)+10\n",
"\n",
"print(add_ten(sum_2,0,1))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.getrecursionlimit()\n",
"#sys.setrecursionlimit()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.54 ms ± 69.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n",
"1.02 ms ± 23.7 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n",
"842 µs ± 22 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
]
}
],
"source": [ "source": [
"# recursion works like this (std limit 3000)\n", "# recursion works like this (std limit 3000)\n",
"def factorial_slow(n):\n", "def factorial_slow(n):\n",
...@@ -982,7 +965,7 @@ ...@@ -982,7 +965,7 @@
" if n==1:\n", " if n==1:\n",
" return n\n", " return n\n",
" else:\n", " else:\n",
" return n*factorial(n-1)\n", " return n*factorial_slow(n-1)\n",
"\n", "\n",
"# lets compare the execution time of recursion to a while loop\n", "# lets compare the execution time of recursion to a while loop\n",
"def factorial_fast(m):\n", "def factorial_fast(m):\n",
...@@ -1013,6 +996,22 @@ ...@@ -1013,6 +996,22 @@
"# for is faster than while\n" "# for is faster than while\n"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# you can even pass functions as function arguments\n",
"def add_ten(func,a,b):\n",
" '''\n",
" my function\n",
" '''\n",
" return func(a,b)+10\n",
"\n",
"print(add_ten(sum_2,0,1))"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
...@@ -1800,7 +1799,7 @@ ...@@ -1800,7 +1799,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.8" "version": "3.7.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment