Удалил Untitled.ipynb
This commit is contained in:
656
Untitled.ipynb
656
Untitled.ipynb
@@ -1,656 +0,0 @@
|
|||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 5,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
" 10\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"100\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%run src-intro/test.py"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 3,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"'/home/svl/Projects/Doconce/python-course/ipynb'"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 3,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%pwd"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 6,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"/home/svl/Projects/Doconce/python-course/ipynb/src-intro\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%cd src-intro"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 7,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Hello from Python!\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%run hello.py"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 10,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%run fib.py"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 11,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"range(0, 5)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 11,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"range(5)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 13,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"<generator object <genexpr> at 0x7f65857f9c80>\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"print(i for i in range(5))"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 14,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"\u001b[0;31mInit signature:\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m/\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;31mDocstring:\u001b[0m \n",
|
|
||||||
"range(stop) -> range object\n",
|
|
||||||
"range(start, stop[, step]) -> range object\n",
|
|
||||||
"\n",
|
|
||||||
"Return an object that produces a sequence of integers from start (inclusive)\n",
|
|
||||||
"to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.\n",
|
|
||||||
"start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.\n",
|
|
||||||
"These are exactly the valid indices for a list of 4 elements.\n",
|
|
||||||
"When step is given, it specifies the increment (or decrement).\n",
|
|
||||||
"\u001b[0;31mType:\u001b[0m type\n",
|
|
||||||
"\u001b[0;31mSubclasses:\u001b[0m \n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "display_data"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"range?"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 18,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"[10, 8, 6, 4, 2]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 18,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"list(range(10,1, -2))"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 19,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%run fib.py"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 25,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"ename": "TypeError",
|
|
||||||
"evalue": "can't multiply sequence by non-int of type 'float'",
|
|
||||||
"output_type": "error",
|
|
||||||
"traceback": [
|
|
||||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
||||||
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
|
||||||
"\u001b[0;32m<ipython-input-25-da4664af34ee>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfib\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1.0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
||||||
"\u001b[0;32m~/Projects/Doconce/python-course/ipynb/src-intro/fib.py\u001b[0m in \u001b[0;36mfib\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 5\u001b[0m \"\"\"\n\u001b[1;32m 6\u001b[0m \u001b[0mf0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mf1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf0\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mf1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;31mTypeError\u001b[0m: can't multiply sequence by non-int of type 'float'"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"fib(1.0)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 26,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> \u001b[0;32m/home/svl/Projects/Doconce/python-course/ipynb/src-intro/fib.py\u001b[0m(7)\u001b[0;36mfib\u001b[0;34m()\u001b[0m\n",
|
|
||||||
"\u001b[0;32m 5 \u001b[0;31m \"\"\"\n",
|
|
||||||
"\u001b[0m\u001b[0;32m 6 \u001b[0;31m \u001b[0mf0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mf1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0m\u001b[0;32m----> 7 \u001b[0;31m \u001b[0mf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0m\u001b[0;32m 8 \u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0m\u001b[0;32m 9 \u001b[0;31m \u001b[0mf\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf0\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mf1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0m\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ipdb> f\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"*** NameError: name 'f' is not defined\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ipdb> f01\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"*** NameError: name 'f01' is not defined\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ipdb> f0\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"0\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ipdb> f1\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"1\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ipdb> n\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%debug"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 23,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"[1]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 23,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"a"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 24,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"[1, 1, 1, 1]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 24,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"a*4"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 27,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"[1]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 27,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"a"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 28,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"[1, 1, 2]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 28,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"fib(3)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 29,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Once deleted, variables cannot be recovered. Proceed (y/[n])? y\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%reset"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 30,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"ename": "NameError",
|
|
||||||
"evalue": "name 'a' is not defined",
|
|
||||||
"output_type": "error",
|
|
||||||
"traceback": [
|
|
||||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
||||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
||||||
"\u001b[0;32m<ipython-input-30-3f786850e387>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
||||||
"\u001b[0;31mNameError\u001b[0m: name 'a' is not defined"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"a"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 31,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"ename": "NameError",
|
|
||||||
"evalue": "name 'fib' is not defined",
|
|
||||||
"output_type": "error",
|
|
||||||
"traceback": [
|
|
||||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
||||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
||||||
"\u001b[0;32m<ipython-input-31-252d5fa3ed3f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfib\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
|
||||||
"\u001b[0;31mNameError\u001b[0m: name 'fib' is not defined"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"fib(4)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 32,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%run fib.py"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 33,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"8.35 µs ± 194 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"%timeit fib(100)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 34,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"CPU times: user 84 µs, sys: 0 ns, total: 84 µs\n",
|
|
||||||
"Wall time: 98.5 µs\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"result = %time fib(100)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 35,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"[1,\n",
|
|
||||||
" 1,\n",
|
|
||||||
" 2,\n",
|
|
||||||
" 3,\n",
|
|
||||||
" 5,\n",
|
|
||||||
" 8,\n",
|
|
||||||
" 13,\n",
|
|
||||||
" 21,\n",
|
|
||||||
" 34,\n",
|
|
||||||
" 55,\n",
|
|
||||||
" 89,\n",
|
|
||||||
" 144,\n",
|
|
||||||
" 233,\n",
|
|
||||||
" 377,\n",
|
|
||||||
" 610,\n",
|
|
||||||
" 987,\n",
|
|
||||||
" 1597,\n",
|
|
||||||
" 2584,\n",
|
|
||||||
" 4181,\n",
|
|
||||||
" 6765,\n",
|
|
||||||
" 10946,\n",
|
|
||||||
" 17711,\n",
|
|
||||||
" 28657,\n",
|
|
||||||
" 46368,\n",
|
|
||||||
" 75025,\n",
|
|
||||||
" 121393,\n",
|
|
||||||
" 196418,\n",
|
|
||||||
" 317811,\n",
|
|
||||||
" 514229,\n",
|
|
||||||
" 832040,\n",
|
|
||||||
" 1346269,\n",
|
|
||||||
" 2178309,\n",
|
|
||||||
" 3524578,\n",
|
|
||||||
" 5702887,\n",
|
|
||||||
" 9227465,\n",
|
|
||||||
" 14930352,\n",
|
|
||||||
" 24157817,\n",
|
|
||||||
" 39088169,\n",
|
|
||||||
" 63245986,\n",
|
|
||||||
" 102334155,\n",
|
|
||||||
" 165580141,\n",
|
|
||||||
" 267914296,\n",
|
|
||||||
" 433494437,\n",
|
|
||||||
" 701408733,\n",
|
|
||||||
" 1134903170,\n",
|
|
||||||
" 1836311903,\n",
|
|
||||||
" 2971215073,\n",
|
|
||||||
" 4807526976,\n",
|
|
||||||
" 7778742049,\n",
|
|
||||||
" 12586269025,\n",
|
|
||||||
" 20365011074,\n",
|
|
||||||
" 32951280099,\n",
|
|
||||||
" 53316291173,\n",
|
|
||||||
" 86267571272,\n",
|
|
||||||
" 139583862445,\n",
|
|
||||||
" 225851433717,\n",
|
|
||||||
" 365435296162,\n",
|
|
||||||
" 591286729879,\n",
|
|
||||||
" 956722026041,\n",
|
|
||||||
" 1548008755920,\n",
|
|
||||||
" 2504730781961,\n",
|
|
||||||
" 4052739537881,\n",
|
|
||||||
" 6557470319842,\n",
|
|
||||||
" 10610209857723,\n",
|
|
||||||
" 17167680177565,\n",
|
|
||||||
" 27777890035288,\n",
|
|
||||||
" 44945570212853,\n",
|
|
||||||
" 72723460248141,\n",
|
|
||||||
" 117669030460994,\n",
|
|
||||||
" 190392490709135,\n",
|
|
||||||
" 308061521170129,\n",
|
|
||||||
" 498454011879264,\n",
|
|
||||||
" 806515533049393,\n",
|
|
||||||
" 1304969544928657,\n",
|
|
||||||
" 2111485077978050,\n",
|
|
||||||
" 3416454622906707,\n",
|
|
||||||
" 5527939700884757,\n",
|
|
||||||
" 8944394323791464,\n",
|
|
||||||
" 14472334024676221,\n",
|
|
||||||
" 23416728348467685,\n",
|
|
||||||
" 37889062373143906,\n",
|
|
||||||
" 61305790721611591,\n",
|
|
||||||
" 99194853094755497,\n",
|
|
||||||
" 160500643816367088,\n",
|
|
||||||
" 259695496911122585,\n",
|
|
||||||
" 420196140727489673,\n",
|
|
||||||
" 679891637638612258,\n",
|
|
||||||
" 1100087778366101931,\n",
|
|
||||||
" 1779979416004714189,\n",
|
|
||||||
" 2880067194370816120,\n",
|
|
||||||
" 4660046610375530309,\n",
|
|
||||||
" 7540113804746346429,\n",
|
|
||||||
" 12200160415121876738,\n",
|
|
||||||
" 19740274219868223167,\n",
|
|
||||||
" 31940434634990099905,\n",
|
|
||||||
" 51680708854858323072,\n",
|
|
||||||
" 83621143489848422977,\n",
|
|
||||||
" 135301852344706746049,\n",
|
|
||||||
" 218922995834555169026,\n",
|
|
||||||
" 354224848179261915075]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 35,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"result"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.8.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 4
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"<!-- Author: --> \n",
|
"<!-- Author: --> \n",
|
||||||
"**С.В. Лемешевский** (email: `sergey.lemeshevsky@gmail.com`), Институт математики НАН Беларуси\n",
|
"**С.В. Лемешевский** (email: `sergey.lemeshevsky@gmail.com`), Институт математики НАН Беларуси\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Date: **Mar 8, 2020**\n",
|
"Date: **Mar 18, 2020**\n",
|
||||||
"\n",
|
"\n",
|
||||||
"<!-- Common Mako variable and functions -->\n",
|
"<!-- Common Mako variable and functions -->\n",
|
||||||
"<!-- -*- coding: utf-8 -*- -->\n",
|
"<!-- -*- coding: utf-8 -*- -->\n",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"<!-- Author: --> \n",
|
"<!-- Author: --> \n",
|
||||||
"**С.В. Лемешевский** (email: `sergey.lemeshevsky@gmail.com`), Институт математики НАН Беларуси\n",
|
"**С.В. Лемешевский** (email: `sergey.lemeshevsky@gmail.com`), Институт математики НАН Беларуси\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Date: **Mar 4, 2020**\n",
|
"Date: **Mar 18, 2020**\n",
|
||||||
"\n",
|
"\n",
|
||||||
"<!-- Common Mako variable and functions -->\n",
|
"<!-- Common Mako variable and functions -->\n",
|
||||||
"<!-- -*- coding: utf-8 -*- -->\n",
|
"<!-- -*- coding: utf-8 -*- -->\n",
|
||||||
|
|||||||
BIN
fig-numpy/numpy-1.png
Normal file
BIN
fig-numpy/numpy-1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
BIN
fig-numpy/numpy-1.png~
Normal file
BIN
fig-numpy/numpy-1.png~
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
BIN
fig-numpy/numpy-2.png
Normal file
BIN
fig-numpy/numpy-2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
BIN
fig-numpy/numpy-2.png~
Normal file
BIN
fig-numpy/numpy-2.png~
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
BIN
fig-numpy/numpy-3.png
Normal file
BIN
fig-numpy/numpy-3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
184
intro.ipynb
184
intro.ipynb
@@ -10,7 +10,7 @@
|
|||||||
"<!-- Author: --> \n",
|
"<!-- Author: --> \n",
|
||||||
"**С.В. Лемешевский** (email: `sergey.lemeshevsky@gmail.com`), Институт математики НАН Беларуси\n",
|
"**С.В. Лемешевский** (email: `sergey.lemeshevsky@gmail.com`), Институт математики НАН Беларуси\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Date: **Feb 26, 2020**\n",
|
"Date: **Mar 18, 2020**\n",
|
||||||
"\n",
|
"\n",
|
||||||
"<!-- Common Mako variable and functions -->\n",
|
"<!-- Common Mako variable and functions -->\n",
|
||||||
"<!-- -*- coding: utf-8 -*- -->\n",
|
"<!-- -*- coding: utf-8 -*- -->\n",
|
||||||
@@ -354,10 +354,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -430,10 +427,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 2,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -556,10 +550,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 3,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -669,10 +660,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 4,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -760,10 +748,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 5,
|
"execution_count": 5,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -774,10 +759,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 6,
|
"execution_count": 6,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -788,10 +770,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 7,
|
"execution_count": 7,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -802,10 +781,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 8,
|
"execution_count": 8,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -816,10 +792,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": 9,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -845,10 +818,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 10,
|
"execution_count": 10,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -859,10 +829,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 11,
|
"execution_count": 11,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -873,10 +840,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 12,
|
"execution_count": 12,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -887,10 +851,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 13,
|
"execution_count": 13,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -940,10 +901,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 14,
|
"execution_count": 14,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -954,10 +912,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 15,
|
"execution_count": 15,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -988,10 +943,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 16,
|
"execution_count": 16,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1015,10 +967,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 17,
|
"execution_count": 17,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1029,10 +978,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 18,
|
"execution_count": 18,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1043,10 +989,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 19,
|
"execution_count": 19,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1065,10 +1008,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 20,
|
"execution_count": 20,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1079,10 +1019,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 21,
|
"execution_count": 21,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1114,10 +1051,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 22,
|
"execution_count": 22,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1157,10 +1091,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 23,
|
"execution_count": 23,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1212,10 +1143,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 24,
|
"execution_count": 24,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1226,10 +1154,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 25,
|
"execution_count": 25,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1240,10 +1165,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 26,
|
"execution_count": 26,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1284,10 +1206,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 27,
|
"execution_count": 27,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1311,10 +1230,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 28,
|
"execution_count": 28,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1384,10 +1300,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 29,
|
"execution_count": 29,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1398,10 +1311,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 30,
|
"execution_count": 30,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1432,10 +1342,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 31,
|
"execution_count": 31,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -1463,10 +1370,7 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 32,
|
"execution_count": 32,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": false,
|
"collapsed": false
|
||||||
"jupyter": {
|
|
||||||
"outputs_hidden": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@@ -2229,25 +2133,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {},
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.8.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 4
|
"nbformat_minor": 2
|
||||||
}
|
}
|
||||||
|
|||||||
3700
numpy.ipynb
Normal file
3700
numpy.ipynb
Normal file
File diff suppressed because it is too large
Load Diff
102
src-collections/generate_usernames_ans.py
Executable file
102
src-collections/generate_usernames_ans.py
Executable file
@@ -0,0 +1,102 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright (c) 2008-11 Qtrac Ltd. All rights reserved.
|
||||||
|
# This program or module is free software: you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version. It is provided for educational
|
||||||
|
# purposes and is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
|
||||||
|
import collections
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
ID, FORENAME, MIDDLENAME, SURNAME, DEPARTMENT = range(5)
|
||||||
|
|
||||||
|
User = collections.namedtuple("User",
|
||||||
|
"username forename middlename surname id")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) == 1 or sys.argv[1] in {"-h", "--help"}:
|
||||||
|
print("usage: {0} file1 [file2 [... fileN]]".format(
|
||||||
|
sys.argv[0]))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
usernames = set()
|
||||||
|
users = {}
|
||||||
|
for filename in sys.argv[1:]:
|
||||||
|
with open(filename, encoding="utf8") as file:
|
||||||
|
for line in file:
|
||||||
|
line = line.rstrip()
|
||||||
|
if line:
|
||||||
|
user = process_line(line, usernames)
|
||||||
|
users[(user.surname.lower(), user.forename.lower(),
|
||||||
|
user.id)] = user
|
||||||
|
print_users(users)
|
||||||
|
|
||||||
|
|
||||||
|
def process_line(line, usernames):
|
||||||
|
fields = line.split(":")
|
||||||
|
username = generate_username(fields, usernames)
|
||||||
|
user = User(username, fields[FORENAME], fields[MIDDLENAME],
|
||||||
|
fields[SURNAME], fields[ID])
|
||||||
|
return user
|
||||||
|
|
||||||
|
|
||||||
|
def generate_username(fields, usernames):
|
||||||
|
username = ((fields[FORENAME][0] + fields[MIDDLENAME][:1] +
|
||||||
|
fields[SURNAME]).replace("-", "").replace("'", ""))
|
||||||
|
username = original_name = username[:8].lower()
|
||||||
|
count = 1
|
||||||
|
while username in usernames:
|
||||||
|
username = "{0}{1}".format(original_name, count)
|
||||||
|
count += 1
|
||||||
|
usernames.add(username)
|
||||||
|
return username
|
||||||
|
|
||||||
|
|
||||||
|
def by_surname_forename(user):
|
||||||
|
return user.surname.lower(), user.forename.lower(), user.id
|
||||||
|
|
||||||
|
|
||||||
|
def print_users(users):
|
||||||
|
namewidth = 17
|
||||||
|
usernamewidth = 9
|
||||||
|
columngap = " " * 2
|
||||||
|
|
||||||
|
headline1 = "{0:<{nw}} {1:^6} {2:{uw}}".format("Name", "ID",
|
||||||
|
"Username", nw=namewidth, uw=usernamewidth)
|
||||||
|
headline2 = "{0:-<{nw}} {0:-<6} {0:-<{uw}}".format("",
|
||||||
|
nw=namewidth, uw=usernamewidth)
|
||||||
|
header = (headline1 + columngap + headline1 + "\n" +
|
||||||
|
headline2 + columngap + headline2)
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
for key in sorted(users):
|
||||||
|
user = users[key]
|
||||||
|
initial = ""
|
||||||
|
if user.middlename:
|
||||||
|
initial = " " + user.middlename[0]
|
||||||
|
name = "{0.surname}, {0.forename}{1}".format(user, initial)
|
||||||
|
lines.append("{0:.<{nw}.{nw}} ({1.id:4}) "
|
||||||
|
"{1.username:{uw}}".format(name, user,
|
||||||
|
nw=namewidth, uw=usernamewidth))
|
||||||
|
|
||||||
|
lines_per_page = 64
|
||||||
|
lino = 0
|
||||||
|
for left, right in zip(lines[::2], lines[1::2]):
|
||||||
|
if lino == 0:
|
||||||
|
print(header)
|
||||||
|
print(left + columngap + right)
|
||||||
|
lino += 1
|
||||||
|
if lino == lines_per_page:
|
||||||
|
print("\f")
|
||||||
|
lino = 0
|
||||||
|
if lines[-1] != right:
|
||||||
|
print(lines[-1])
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
80
src-datatype/.ipynb_checkpoints/csv2html-checkpoint.py~
Normal file
80
src-datatype/.ipynb_checkpoints/csv2html-checkpoint.py~
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
def main():
|
||||||
|
maxwidth = 100
|
||||||
|
print_start()
|
||||||
|
count = 0
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
line = input()
|
||||||
|
if count == 0:
|
||||||
|
color = "lightgreen"
|
||||||
|
elif count % 2:
|
||||||
|
color = "white"
|
||||||
|
else:
|
||||||
|
color = "lightyellow"
|
||||||
|
print_line(line, color, maxwidth)
|
||||||
|
count += 1
|
||||||
|
except EOFError:
|
||||||
|
break
|
||||||
|
print_end()
|
||||||
|
|
||||||
|
def print_start():
|
||||||
|
print("<table border='1'>")
|
||||||
|
|
||||||
|
def print_end():
|
||||||
|
print("</table>")
|
||||||
|
|
||||||
|
def print_line(line, color, maxwidth):
|
||||||
|
print("<tr bgcolor='{0}'>".format(color))
|
||||||
|
fields = extract_fields(line)
|
||||||
|
for field in fields:
|
||||||
|
if not field:
|
||||||
|
print("<td></td>")
|
||||||
|
else:
|
||||||
|
number = field.replace(",", "")
|
||||||
|
try:
|
||||||
|
x = float(number)
|
||||||
|
print("<td align='right'>{0:d}</td>".format(round(x)))
|
||||||
|
except ValueError:
|
||||||
|
field = field.title()
|
||||||
|
field = field.replace(" And ", " and ")
|
||||||
|
field = escape_html(field)
|
||||||
|
if len(field) <= maxwidth:
|
||||||
|
print("<td>{0}</td>".format(field))
|
||||||
|
else:
|
||||||
|
print("<td>{0:.{1}} ...</td>".format(field, maxwidth))
|
||||||
|
print("</tr>")
|
||||||
|
|
||||||
|
def extract_fields(line):
|
||||||
|
fields = []
|
||||||
|
field = ""
|
||||||
|
quote = None
|
||||||
|
for c in line:
|
||||||
|
if c in "\"'":
|
||||||
|
if quote is None: # начало строки в кавычках
|
||||||
|
quote = c
|
||||||
|
elif quote == c: # конец строки в кавычках
|
||||||
|
quote = None
|
||||||
|
else:
|
||||||
|
field += c
|
||||||
|
# другая кавычка внутри строки в кавычках
|
||||||
|
continue
|
||||||
|
if quote is None and c == ",": # end of a field
|
||||||
|
fields.append(field)
|
||||||
|
field = ""
|
||||||
|
else:
|
||||||
|
field += c
|
||||||
|
# добавить символ в поле
|
||||||
|
if field:
|
||||||
|
fields.append(field) # добавить последнее поле в список
|
||||||
|
return fields
|
||||||
|
|
||||||
|
def escape_html(text):
|
||||||
|
text = text.replace("&", "&")
|
||||||
|
text = text.replace("<", "<")
|
||||||
|
text = text.replace(">", ">")
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
33
src-datatype/.ipynb_checkpoints/print_unicode-checkpoint.py~
Normal file
33
src-datatype/.ipynb_checkpoints/print_unicode-checkpoint.py~
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import sys
|
||||||
|
import unicodedata
|
||||||
|
|
||||||
|
def print_unicode_table(word):
|
||||||
|
print("decimal hex chr {0:^40}".format("name"))
|
||||||
|
print("------- ----- --- {0:-<40}".format(""))
|
||||||
|
|
||||||
|
code = ord(" ")
|
||||||
|
end = sys.maxunicode
|
||||||
|
|
||||||
|
while code < end:
|
||||||
|
c = chr(code)
|
||||||
|
name = unicodedata.name(c, "*** unknown ***")
|
||||||
|
if word is None or word in name.lower():
|
||||||
|
print("{0:7} {0:5X} {0:^3c} {1}".format(code, name.title()))
|
||||||
|
code += 1
|
||||||
|
# End print_unicode_table
|
||||||
|
|
||||||
|
# Start main script
|
||||||
|
word = None
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
if sys.argv[1] in ("-h", "--help"):
|
||||||
|
print("usage: {0} [string]".format(sys.argv[0]))
|
||||||
|
word = 0
|
||||||
|
else:
|
||||||
|
word = sys.argv[1].lower()
|
||||||
|
|
||||||
|
if word != 0:
|
||||||
|
print_unicode_table(word)
|
||||||
|
|
||||||
|
#End main script
|
||||||
50
src-datatype/.ipynb_checkpoints/quadratic-checkpoint.py~
Normal file
50
src-datatype/.ipynb_checkpoints/quadratic-checkpoint.py~
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import cmath
|
||||||
|
import math
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Start get_float
|
||||||
|
def get_float(msg, allow_zero):
|
||||||
|
x = None
|
||||||
|
while x is None:
|
||||||
|
try:
|
||||||
|
x = float(input(msg))
|
||||||
|
if not allow_zero and abs(x) < sys.float_info.epsilon:
|
||||||
|
print("zero is not allowed")
|
||||||
|
x = None
|
||||||
|
|
||||||
|
except ValueError as err:
|
||||||
|
print(err)
|
||||||
|
return x
|
||||||
|
# End get_float
|
||||||
|
|
||||||
|
|
||||||
|
# Start 1st block
|
||||||
|
print("ax\N{SUPERSCRIPT TWO} + bx + c = 0")
|
||||||
|
a = get_float("enter a: ", False)
|
||||||
|
b = get_float("enter b: ", False)
|
||||||
|
c = get_float("enter c: ", False)
|
||||||
|
# End 1st block
|
||||||
|
|
||||||
|
# Start 2d block
|
||||||
|
x1 = None
|
||||||
|
x2 = None
|
||||||
|
discriminant = (b ** 2) - (4 * a * c)
|
||||||
|
if discriminant == 0:
|
||||||
|
x1 = -(b / (2 * a))
|
||||||
|
else:
|
||||||
|
if discriminant > 0:
|
||||||
|
root = math.sqrt(discriminant)
|
||||||
|
else: # discriminant < 0
|
||||||
|
root = cmath.sqrt(discriminant)
|
||||||
|
x1 = (-b + root) / (2 * a)
|
||||||
|
x2 = (-b - root) / (2 * a)
|
||||||
|
# End 2d block
|
||||||
|
|
||||||
|
# Start 3d block
|
||||||
|
equation = ("{0}x\N{SUPERSCRIPT TWO} + {1}x + {2} = 0"
|
||||||
|
" \N{RIGHTWARDS ARROW} x = {3}").format(a, b, c, x1)
|
||||||
|
if x2 is not None:
|
||||||
|
equation += " or x = {0}".format(x2)
|
||||||
|
print(equation)
|
||||||
|
# End 3d block
|
||||||
@@ -76,5 +76,4 @@ def escape_html(text):
|
|||||||
text = text.replace(">", ">")
|
text = text.replace(">", ">")
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
BIN
src-numpy/array_archive.npz
Normal file
BIN
src-numpy/array_archive.npz
Normal file
Binary file not shown.
BIN
src-numpy/arrays_compressed.npz
Normal file
BIN
src-numpy/arrays_compressed.npz
Normal file
Binary file not shown.
8
src-numpy/random_walk_numpy.py
Normal file
8
src-numpy/random_walk_numpy.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
nsteps = 1000
|
||||||
|
draws = np.random.randint(0, 2, size=nsteps)
|
||||||
|
steps = np.where(draws > 0, 1, -1)
|
||||||
|
walk = steps.cumsum()
|
||||||
17
src-numpy/random_walk_pure.py
Normal file
17
src-numpy/random_walk_pure.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import random
|
||||||
|
|
||||||
|
position = 0
|
||||||
|
walk = [position]
|
||||||
|
steps = 1000
|
||||||
|
for i in range(100):
|
||||||
|
step = 1 if random.randint(0, 1) else -1
|
||||||
|
position += step
|
||||||
|
walk.append(position)
|
||||||
|
|
||||||
|
plt.plot(walk[:100])
|
||||||
|
plt.savefig('numpy-3.png')
|
||||||
|
|
||||||
|
|
||||||
BIN
src-numpy/some_array.npy
Normal file
BIN
src-numpy/some_array.npy
Normal file
Binary file not shown.
Reference in New Issue
Block a user