Browse Source

Imrpove descriptions

master
bushuhui 2 years ago
parent
commit
788a97cf7e
13 changed files with 1128 additions and 888 deletions
  1. +30
    -28
      0_python/3_Data_Structure_1.ipynb
  2. +72
    -67
      0_python/4_Data_Structure_2.ipynb
  3. +42
    -33
      0_python/5_Control_Flow.ipynb
  4. +103
    -67
      0_python/6_Function.ipynb
  5. +122
    -85
      0_python/7_Class.ipynb
  6. +446
    -457
      1_numpy_matplotlib_scipy_sympy/1-numpy_tutorial.ipynb
  7. +38
    -56
      1_numpy_matplotlib_scipy_sympy/2-matplotlib_tutorial.ipynb
  8. +103
    -35
      1_numpy_matplotlib_scipy_sympy/4-scipy_tutorial.ipynb
  9. +64
    -22
      1_numpy_matplotlib_scipy_sympy/5-sympy_tutorial.ipynb
  10. +13
    -5
      1_numpy_matplotlib_scipy_sympy/bokeh_tutorial.ipynb
  11. +88
    -30
      1_numpy_matplotlib_scipy_sympy/matplotlib_full.ipynb
  12. BIN
      1_numpy_matplotlib_scipy_sympy/random-matrix.npy
  13. +7
    -3
      2_knn/knn_classification.ipynb

+ 30
- 28
0_python/3_Data_Structure_1.ipynb View File

@@ -1825,7 +1825,7 @@
},
{
"cell_type": "code",
"execution_count": 85,
"execution_count": 1,
"metadata": {},
"outputs": [
{
@@ -1843,7 +1843,7 @@
},
{
"cell_type": "code",
"execution_count": 86,
"execution_count": 2,
"metadata": {},
"outputs": [
{
@@ -1861,7 +1861,7 @@
},
{
"cell_type": "code",
"execution_count": 87,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -1893,7 +1893,7 @@
},
{
"cell_type": "code",
"execution_count": 101,
"execution_count": 4,
"metadata": {
"collapsed": true
},
@@ -1904,7 +1904,7 @@
},
{
"cell_type": "code",
"execution_count": 102,
"execution_count": 5,
"metadata": {
"collapsed": true
},
@@ -1922,7 +1922,7 @@
},
{
"cell_type": "code",
"execution_count": 90,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -1931,7 +1931,7 @@
"{1, 2, 3, 4, 5}"
]
},
"execution_count": 90,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -1949,30 +1949,30 @@
},
{
"cell_type": "code",
"execution_count": 94,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{0, 1, 2, 3}\n"
"{0, 1, 2, 3, 10}\n"
]
},
{
"data": {
"text/plain": [
"{0, 1, 2, 3}"
"{0, 1, 2, 3, 5, 10}"
]
},
"execution_count": 94,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"print(set1)\n",
"set1.add(0)\n",
"set1.add(5)\n",
"set1"
]
},
@@ -1985,16 +1985,16 @@
},
{
"cell_type": "code",
"execution_count": 95,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{2, 3}"
"{2, 3, 5}"
]
},
"execution_count": 95,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -2012,24 +2012,24 @@
},
{
"cell_type": "code",
"execution_count": 96,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{0, 1, 2, 3}\n",
"{0, 1, 2, 3, 5, 10}\n",
"{2, 3, 4, 5}\n"
]
},
{
"data": {
"text/plain": [
"{0, 1}"
"{0, 1, 10}"
]
},
"execution_count": 96,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -2049,7 +2049,7 @@
},
{
"cell_type": "code",
"execution_count": 97,
"execution_count": 19,
"metadata": {
"collapsed": true
},
@@ -2060,18 +2060,20 @@
},
{
"cell_type": "code",
"execution_count": 99,
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{4, 9, 10}\n"
"{10, 2, 4, 1}\n",
"{2, 4, 1}\n"
]
}
],
"source": [
"print(set1)\n",
"set1.pop()\n",
"print(set1)"
]
@@ -2085,16 +2087,16 @@
},
{
"cell_type": "code",
"execution_count": 103,
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{1, 3}"
"{1, 4}"
]
},
"execution_count": 103,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -2113,7 +2115,7 @@
},
{
"cell_type": "code",
"execution_count": 104,
"execution_count": 23,
"metadata": {},
"outputs": [
{
@@ -2122,7 +2124,7 @@
"set()"
]
},
"execution_count": 104,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
@@ -2149,7 +2151,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 72
- 67
0_python/4_Data_Structure_2.ipynb View File

@@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 7,
"metadata": {
"collapsed": true
},
@@ -28,12 +28,14 @@
"String1 = \"Taj Mahal is beautiful\"\n",
"String2 = '''Taj Mahal\n",
"is\n",
"beautiful'''"
"beautiful'''\n",
"String3 = \"\"\"Multi-line\n",
"string\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -44,14 +46,17 @@
"Taj Mahal is beautiful <class 'str'>\n",
"Taj Mahal\n",
"is\n",
"beautiful <class 'str'>\n"
"beautiful <class 'str'>\n",
"Multi-line\n",
"string <class 'str'>\n"
]
}
],
"source": [
"print(String0, type(String0))\n",
"print(String1, type(String1))\n",
"print(String2, type(String2))"
"print(String2, type(String2))\n",
"print(String3, type(String3))"
]
},
{
@@ -63,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -98,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -176,7 +181,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@@ -201,7 +206,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@@ -210,7 +215,7 @@
"' Taj Mahal is beautiful '"
]
},
"execution_count": 9,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -228,7 +233,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@@ -237,7 +242,7 @@
"'------------------------Taj Mahal is beautiful------------------------'"
]
},
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -255,7 +260,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"metadata": {},
"outputs": [
{
@@ -264,7 +269,7 @@
"'00000000Taj Mahal is beautiful'"
]
},
"execution_count": 11,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@@ -282,7 +287,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -313,7 +318,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 17,
"metadata": {},
"outputs": [
{
@@ -331,7 +336,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-13-a7d6b97b4839>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mString0\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Taj'\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 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mString0\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Mahal'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\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[0;32m----> 3\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mString0\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Mahal'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m20\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<ipython-input-17-146ef93bc1cd>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mString0\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Taj'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mString0\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Mahal'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mString0\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Mahal'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mValueError\u001b[0m: substring not found"
]
}
@@ -351,7 +356,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -375,7 +380,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 19,
"metadata": {},
"outputs": [
{
@@ -401,7 +406,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 20,
"metadata": {},
"outputs": [
{
@@ -427,7 +432,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 21,
"metadata": {},
"outputs": [
{
@@ -436,7 +441,7 @@
"'*a_a-'"
]
},
"execution_count": 17,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@@ -447,7 +452,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@@ -456,7 +461,7 @@
"'1\\n2'"
]
},
"execution_count": 18,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -481,7 +486,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 25,
"metadata": {},
"outputs": [
{
@@ -509,7 +514,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 27,
"metadata": {},
"outputs": [
{
@@ -534,7 +539,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 28,
"metadata": {},
"outputs": [
{
@@ -559,7 +564,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 29,
"metadata": {},
"outputs": [
{
@@ -586,7 +591,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 30,
"metadata": {},
"outputs": [
{
@@ -612,7 +617,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 31,
"metadata": {},
"outputs": [
{
@@ -621,7 +626,7 @@
"'TAJ MAHAL IS BEAUTIFUL'"
]
},
"execution_count": 23,
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
@@ -639,7 +644,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 32,
"metadata": {},
"outputs": [
{
@@ -648,7 +653,7 @@
"'Bengaluru is beautiful'"
]
},
"execution_count": 24,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
@@ -666,7 +671,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 33,
"metadata": {
"collapsed": true
},
@@ -684,7 +689,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 34,
"metadata": {},
"outputs": [
{
@@ -693,7 +698,7 @@
"'hello'"
]
},
"execution_count": 27,
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
@@ -711,7 +716,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 35,
"metadata": {
"collapsed": true
},
@@ -722,7 +727,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 36,
"metadata": {},
"outputs": [
{
@@ -731,7 +736,7 @@
"'hello'"
]
},
"execution_count": 32,
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
@@ -749,7 +754,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 37,
"metadata": {},
"outputs": [
{
@@ -775,7 +780,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 38,
"metadata": {},
"outputs": [
{
@@ -815,7 +820,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 39,
"metadata": {},
"outputs": [
{
@@ -841,7 +846,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 41,
"metadata": {},
"outputs": [
{
@@ -860,7 +865,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 42,
"metadata": {},
"outputs": [
{
@@ -885,7 +890,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 43,
"metadata": {},
"outputs": [
{
@@ -909,7 +914,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 44,
"metadata": {
"collapsed": true
},
@@ -928,14 +933,14 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'One': 1, 'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5}\n"
"{'One': 1, 'Three': 3, 'Five': 5, 'Four': 4, 'Two': 2}\n"
]
}
],
@@ -946,14 +951,14 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 46,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'One': 1, 'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5}\n"
"{'One': 1, 'Three': 3, 'Five': 5, 'Four': 4, 'Two': 2}\n"
]
}
],
@@ -1007,7 +1012,7 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 47,
"metadata": {},
"outputs": [
{
@@ -1033,14 +1038,14 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'One': 1, 'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5}\n"
"{'One': 1, 'Three': 3, 'Five': 5, 'Four': 4, 'Two': 2}\n"
]
}
],
@@ -1051,14 +1056,14 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 49,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'One': 1, 'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5}\n"
"{'One': 1, 'Three': 3, 'Five': 5, 'Four': 4, 'Two': 2}\n"
]
}
],
@@ -1077,16 +1082,16 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_values([1, 2, 3, 4, 5])"
"dict_values([1, 3, 5, 4, 2])"
]
},
"execution_count": 46,
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
@@ -1104,16 +1109,16 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['One', 'Two', 'Three', 'Four', 'Five'])"
"dict_keys(['One', 'Three', 'Five', 'Four', 'Two'])"
]
},
"execution_count": 47,
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
@@ -1131,7 +1136,7 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 52,
"metadata": {},
"outputs": [
{
@@ -1139,10 +1144,10 @@
"output_type": "stream",
"text": [
"[ One] 1\n",
"[ Two] 2\n",
"[ Three] 3\n",
"[ Five] 5\n",
"[ Four] 4\n",
"[ Five] 5\n"
"[ Two] 2\n"
]
}
],
@@ -1162,7 +1167,7 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 55,
"metadata": {},
"outputs": [
{
@@ -1172,7 +1177,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-52-436d4737aff5>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ma2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0ma1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'One'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-55-d348bc398654>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ma2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0ma1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'One'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyError\u001b[0m: 'One'"
]
}
@@ -1200,7 +1205,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 42
- 33
0_python/5_Control_Flow.ipynb View File

@@ -28,7 +28,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 7,
"metadata": {
"scrolled": true
},
@@ -37,7 +37,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome!\n"
"Welcome!\n",
"Too\n"
]
}
],
@@ -46,19 +47,27 @@
"if x >10: \n",
" print(\"Hello\")\n",
"else: \n",
" print(\"Welcome!\")"
" print(\"Welcome!\")\n",
" print(\"Too\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello\n",
"2\n"
]
}
],
"source": [
"x = 4\n",
"if x > 10: print(\"Hello\")"
"x = 14\n",
"if x > 10: print(\"Hello\"); print(\"2\")"
]
},
{
@@ -86,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -134,7 +143,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -220,7 +229,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -242,7 +251,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@@ -257,7 +266,7 @@
}
],
"source": [
"a = [1, 2, 5, 6]\n",
"a = (1, 2, 5, 6)\n",
"for i in a:\n",
" print(i)"
]
@@ -271,7 +280,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@@ -299,7 +308,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 14,
"metadata": {},
"outputs": [
{
@@ -350,7 +359,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 17,
"metadata": {},
"outputs": [
{
@@ -490,7 +499,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -518,7 +527,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 19,
"metadata": {},
"outputs": [
{
@@ -527,7 +536,7 @@
"[27, 54, 81, 108, 135, 162, 189, 216, 243, 270]"
]
},
"execution_count": 11,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -554,7 +563,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 20,
"metadata": {},
"outputs": [
{
@@ -563,7 +572,7 @@
"[27, 54, 81, 108, 135, 162, 189, 216, 243, 270]"
]
},
"execution_count": 12,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
@@ -574,7 +583,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 21,
"metadata": {
"scrolled": true
},
@@ -582,19 +591,19 @@
{
"data": {
"text/plain": [
"{'27': 27,\n",
" '54': 54,\n",
" '81': 81,\n",
" '108': 108,\n",
"{'108': 108,\n",
" '135': 135,\n",
" '162': 162,\n",
" '189': 189,\n",
" '216': 216,\n",
" '243': 243,\n",
" '270': 270}"
" '27': 27,\n",
" '270': 270,\n",
" '54': 54,\n",
" '81': 81}"
]
},
"execution_count": 13,
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@@ -605,7 +614,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@@ -614,7 +623,7 @@
"(27, 54, 81, 108, 135, 162, 189, 216, 243, 270)"
]
},
"execution_count": 14,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -667,7 +676,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 103
- 67
0_python/6_Function.ipynb View File

@@ -69,8 +69,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def first_func():\n",
@@ -80,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -109,8 +111,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def first_func(username):\n",
@@ -120,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -144,7 +148,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -169,8 +173,10 @@
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def first_func(username):\n",
@@ -183,7 +189,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -216,8 +222,10 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"execution_count": 14,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def times(x,y):\n",
@@ -234,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@@ -266,8 +274,10 @@
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"execution_count": 16,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def times(x,y):\n",
@@ -277,7 +287,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -302,7 +312,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 19,
"metadata": {
"scrolled": true
},
@@ -325,8 +335,10 @@
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"execution_count": 20,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"times?"
@@ -341,8 +353,10 @@
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"execution_count": 21,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eglist = [10,50,30,12,6,8,100]"
@@ -350,8 +364,10 @@
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"execution_count": 23,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def egfunc(eglist):\n",
@@ -371,7 +387,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 24,
"metadata": {},
"outputs": [
{
@@ -389,7 +405,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 25,
"metadata": {},
"outputs": [
{
@@ -424,8 +440,10 @@
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"execution_count": 27,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def implicit_add(x, addnumber=3):\n",
@@ -448,7 +466,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 28,
"metadata": {},
"outputs": [
{
@@ -457,7 +475,7 @@
"7"
]
},
"execution_count": 21,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
@@ -475,7 +493,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 29,
"metadata": {},
"outputs": [
{
@@ -484,7 +502,7 @@
"8"
]
},
"execution_count": 22,
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
@@ -495,7 +513,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 30,
"metadata": {},
"outputs": [
{
@@ -504,7 +522,7 @@
"11"
]
},
"execution_count": 23,
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
@@ -529,8 +547,10 @@
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"execution_count": 31,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def add_n(*args):\n",
@@ -612,13 +632,14 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['x', 'y', 'c']\n",
"[10, 20, 30]\n"
]
},
@@ -628,7 +649,7 @@
"60"
]
},
"execution_count": 28,
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
@@ -637,8 +658,11 @@
"def add_nd(**kwargs):\n",
" res = 0\n",
" reslist = []\n",
" namelist = []\n",
" for (k,v) in kwargs.items():\n",
" reslist.append(v)\n",
" namelist.append(k)\n",
" print(namelist)\n",
" print(reslist)\n",
" return sum(reslist)\n",
"\n",
@@ -661,8 +685,10 @@
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"execution_count": 34,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eg1 = [1,2,3,4,5]"
@@ -677,8 +703,10 @@
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"execution_count": 36,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def egfunc1():\n",
@@ -697,7 +725,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 37,
"metadata": {},
"outputs": [
{
@@ -743,8 +771,10 @@
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"execution_count": 39,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"z = lambda x: x * x"
@@ -752,7 +782,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 40,
"metadata": {},
"outputs": [
{
@@ -761,7 +791,7 @@
"64"
]
},
"execution_count": 33,
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
@@ -772,7 +802,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 43,
"metadata": {},
"outputs": [
{
@@ -781,7 +811,7 @@
"(6, 8)"
]
},
"execution_count": 35,
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
@@ -793,7 +823,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 44,
"metadata": {},
"outputs": [
{
@@ -802,7 +832,7 @@
"function"
]
},
"execution_count": 36,
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
@@ -813,7 +843,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 45,
"metadata": {},
"outputs": [
{
@@ -822,7 +852,7 @@
"function"
]
},
"execution_count": 37,
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
@@ -850,8 +880,10 @@
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"execution_count": 46,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"list1 = [1,2,3,4,5,6,7,8,9]"
@@ -859,7 +891,7 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 49,
"metadata": {},
"outputs": [
{
@@ -877,7 +909,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 50,
"metadata": {},
"outputs": [
{
@@ -902,8 +934,10 @@
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"execution_count": 51,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"list2 = [9,8,7,6,5,4,3,2,1]"
@@ -911,7 +945,7 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 53,
"metadata": {},
"outputs": [
{
@@ -936,14 +970,14 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 54,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<map object at 0x7f7bb06e1610>\n"
"<map object at 0x7fa57c194278>\n"
]
}
],
@@ -968,8 +1002,10 @@
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"execution_count": 55,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"list1 = [1,2,3,4,5,6,7,8,9]"
@@ -984,7 +1020,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 57,
"metadata": {},
"outputs": [
{
@@ -1009,7 +1045,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 58,
"metadata": {},
"outputs": [
{
@@ -1018,7 +1054,7 @@
"[True, True, True, True, False, False, False, False, False]"
]
},
"execution_count": 47,
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
@@ -1071,7 +1107,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 122
- 85
0_python/7_Class.ipynb View File

@@ -14,10 +14,10 @@
"Python中的变量、列表、字典等其实都是类,因为Python从设计之初就已经是一门面向对象的语言。\n",
"\n",
"本节常见的定义和概念定义:\n",
"* 类(Class): 用来描述具有相同的属性和方法的对象的集合。它定义了该集合中每个对象所共有的属性和方法。对象是类的实例\n",
"* 对象:通过类定义的数据结构实例。对象包括两个数据成员(类变量和实例变量)和方法。例如我们定义了一个 `Person` 类,而具体的人,比如小明,小黄就是 `Person` 类的实例\n",
"* 类(Class): 用来描述具有相同的属性和方法的对象的集合。它定义了该集合中每个对象所共有的属性和方法。对象是类的实例\n",
"* 对象(Object):通过类定义的数据结构实例(Instance),对象包括两类成员(类变量和实例变量)和方法。例如我们定义了一个 `Person` 类,而具体的人,比如小明,小黄就是 `Person` 类的实例\n",
"* 属性: 描述该类具有的特征,比如人类具备的属性,身份证,姓名,性别,身高,体重等等都是属性\n",
"* 方法:该类对象的行为,例如这个男孩会打篮球,那个女孩会唱歌等等都是属于方法,常常通过方法改变一些类中的属性值"
"* 方法: 该类对象的行为,例如这个男孩会打篮球,那个女孩会唱歌等等都是属于方法,常常通过方法改变一些类中的属性值"
]
},
{
@@ -40,8 +40,10 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 一个最简单的类\n",
@@ -53,7 +55,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**pass** 在Python中意味着什么都不做。 "
"NOTE: **pass** 在Python中意味着什么都不做。 "
]
},
{
@@ -65,8 +67,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"egclass = FirstClass()"
@@ -74,7 +78,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -83,7 +87,7 @@
"__main__.FirstClass"
]
},
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -123,7 +127,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"大多数类都有一个名为`__init__`的函数这些被称为魔术方法。在这个方法中,你基本上初始化了这个类的变量,或者任何适用于这个方法中指定的所有方法的初始化算法。类中的变量称为属性。"
"大多数类都有一个名为`__init__`的函数这些被称为魔术方法。在这个方法中,你基本上初始化了这个类的变量,或者任何适用于这个方法中指定的所有方法的初始化算法。类中的变量称为属性。"
]
},
{
@@ -144,8 +148,10 @@
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class FirstClass:\n",
@@ -166,7 +172,9 @@
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eg1 = FirstClass('one',1)\n",
@@ -175,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -203,7 +211,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {
"scrolled": false
},
@@ -223,7 +231,6 @@
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
@@ -240,7 +247,7 @@
" 'class_var']"
]
},
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -251,7 +258,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"outputs": [
{
@@ -260,7 +267,7 @@
"'My first class'"
]
},
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -278,7 +285,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@@ -296,7 +303,6 @@
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
@@ -315,7 +321,7 @@
" 'value']"
]
},
"execution_count": 12,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -333,8 +339,10 @@
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"execution_count": 14,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class FirstClass:\n",
@@ -352,8 +360,10 @@
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"execution_count": 15,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eg1 = FirstClass('one',1)\n",
@@ -362,7 +372,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -372,7 +382,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-15-4ab7dec1c737>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0meg1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meg1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0meg2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meg2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-16-5eb87775240a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0meg1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meg1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0meg2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meg2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msymbol\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: 'FirstClass' object has no attribute 'name'"
]
}
@@ -391,7 +401,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"metadata": {},
"outputs": [
{
@@ -409,7 +419,6 @@
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
@@ -427,7 +436,7 @@
" 'v']"
]
},
"execution_count": 16,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -438,7 +447,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -470,8 +479,10 @@
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"execution_count": 19,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class FirstClass:\n",
@@ -482,8 +493,10 @@
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"execution_count": 20,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eg1 = FirstClass('one',1)\n",
@@ -492,7 +505,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 21,
"metadata": {},
"outputs": [
{
@@ -518,8 +531,10 @@
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"execution_count": 22,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eg1.cube = 1\n",
@@ -528,7 +543,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 23,
"metadata": {},
"outputs": [
{
@@ -546,7 +561,6 @@
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
@@ -565,7 +579,7 @@
" 'v']"
]
},
"execution_count": 19,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
@@ -589,8 +603,10 @@
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"execution_count": 24,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class FirstClass:\n",
@@ -609,7 +625,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 25,
"metadata": {},
"outputs": [
{
@@ -629,7 +645,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 26,
"metadata": {},
"outputs": [
{
@@ -653,8 +669,10 @@
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"execution_count": 28,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class FirstClass:\n",
@@ -671,8 +689,10 @@
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"execution_count": 29,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eg4 = FirstClass('Five',5)"
@@ -680,7 +700,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 30,
"metadata": {},
"outputs": [
{
@@ -767,8 +787,10 @@
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"execution_count": 31,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class Person:\n",
@@ -782,8 +804,10 @@
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"execution_count": 32,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"a = Person('Jerry',26)"
@@ -791,7 +815,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 33,
"metadata": {},
"outputs": [
{
@@ -808,7 +832,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 34,
"metadata": {},
"outputs": [
{
@@ -826,7 +850,6 @@
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
@@ -843,7 +866,7 @@
" 'salary']"
]
},
"execution_count": 32,
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
@@ -861,8 +884,10 @@
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"execution_count": 35,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class Artist:\n",
@@ -879,8 +904,10 @@
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"execution_count": 36,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"b = Artist('Nick',20)"
@@ -888,7 +915,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 37,
"metadata": {},
"outputs": [
{
@@ -907,7 +934,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 38,
"metadata": {},
"outputs": [
{
@@ -925,7 +952,6 @@
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
@@ -943,7 +969,7 @@
" 'salary']"
]
},
"execution_count": 37,
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
@@ -961,8 +987,10 @@
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"execution_count": 40,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class Artist(Person):\n",
@@ -973,8 +1001,10 @@
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"execution_count": 41,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"c = Artist('Tom',21)"
@@ -982,7 +1012,7 @@
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 42,
"metadata": {},
"outputs": [
{
@@ -1000,7 +1030,6 @@
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
@@ -1018,7 +1047,7 @@
" 'salary']"
]
},
"execution_count": 41,
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
@@ -1029,7 +1058,7 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 43,
"metadata": {},
"outputs": [
{
@@ -1055,8 +1084,10 @@
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"execution_count": 45,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class Artist(Person):\n",
@@ -1071,8 +1102,10 @@
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"execution_count": 46,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"c = Artist('Tom',21)"
@@ -1080,7 +1113,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 47,
"metadata": {},
"outputs": [
{
@@ -1107,8 +1140,10 @@
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"execution_count": 48,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"class NotSure:\n",
@@ -1119,7 +1154,9 @@
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"yz = NotSure('I', 'Do' , 'Not', 'Know', 'What', 'To','Type')"
@@ -1198,7 +1235,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 446
- 457
1_numpy_matplotlib_scipy_sympy/1-numpy_tutorial.ipynb
File diff suppressed because it is too large
View File


+ 38
- 56
1_numpy_matplotlib_scipy_sympy/2-matplotlib_tutorial.ipynb
File diff suppressed because it is too large
View File


+ 103
- 35
1_numpy_matplotlib_scipy_sympy/4-scipy_tutorial.ipynb View File

@@ -19,7 +19,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 这一行的作用会在第四节讲到\n",
@@ -70,7 +72,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import scipy.linalg as la"
@@ -95,7 +99,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# scipy.special模块包含了一系列的贝塞尔函数\n",
@@ -210,7 +216,9 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy.integrate import quad, dblquad, tplquad"
@@ -228,7 +236,9 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 定义一个简单的被积函数\n",
@@ -393,7 +403,9 @@
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy.integrate import odeint, ode"
@@ -489,7 +501,9 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"g = 9.82\n",
@@ -513,7 +527,9 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 选择一个初始状态\n",
@@ -523,7 +539,9 @@
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 解决常微分方程的坐标:从0到10秒\n",
@@ -533,7 +551,9 @@
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 解决常微分方程\n",
@@ -588,7 +608,9 @@
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from IPython.display import display, clear_output\n",
@@ -686,7 +708,9 @@
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def dy(y, t, zeta, w0):\n",
@@ -704,7 +728,9 @@
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 初始状态: \n",
@@ -714,7 +740,9 @@
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 为了求解常微分方程的时间坐标\n",
@@ -725,7 +753,9 @@
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 求解阻尼比的三个不同值的ODE问题\n",
@@ -780,7 +810,9 @@
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from numpy.fft import fftfreq\n",
@@ -797,7 +829,9 @@
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"N = len(t)\n",
@@ -844,7 +878,9 @@
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"indices = where(w > 0) # 仅仅选取对应正频率的元素索引\n",
@@ -920,7 +956,9 @@
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy.linalg import *\n",
@@ -930,7 +968,9 @@
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"A = np.array([[1,2], [4,5]])\n",
@@ -994,7 +1034,9 @@
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"A = rand(3,3)\n",
@@ -1004,7 +1046,9 @@
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"X = solve(A, B)"
@@ -1076,7 +1120,9 @@
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"evals = eigvals(A)"
@@ -1105,7 +1151,9 @@
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"evals, evecs = eig(A)"
@@ -1282,7 +1330,9 @@
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy.sparse import *"
@@ -1673,7 +1723,9 @@
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy import optimize"
@@ -1696,7 +1748,9 @@
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def f(x):\n",
@@ -1865,7 +1919,9 @@
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"omega_c = 3.0\n",
@@ -1988,7 +2044,9 @@
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#FIXME: use as\n",
@@ -1998,7 +2056,9 @@
{
"cell_type": "code",
"execution_count": 79,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def f(x):\n",
@@ -2008,7 +2068,9 @@
{
"cell_type": "code",
"execution_count": 80,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"n = arange(0, 10) \n",
@@ -2068,7 +2130,9 @@
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from scipy import stats"
@@ -2077,7 +2141,9 @@
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 创建一个(离散的)具有泊松分布的随机变量\n",
@@ -2121,7 +2187,9 @@
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 创建一个(连续的)正态分布的随机变量\n",
@@ -2357,7 +2425,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 64
- 22
1_numpy_matplotlib_scipy_sympy/5-sympy_tutorial.ipynb View File

@@ -19,7 +19,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline\n",
@@ -52,7 +54,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import sympy as sp"
@@ -68,7 +72,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"sp.init_printing()\n",
@@ -96,7 +102,9 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = sp.Symbol('x')"
@@ -130,7 +138,9 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# 定义符号的可替代的方式\n",
@@ -167,7 +177,9 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = sp.Symbol('x', real=True)"
@@ -196,7 +208,9 @@
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = sp.Symbol('x', positive=True)"
@@ -330,7 +344,9 @@
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"r1 = sp.Rational(4,5)\n",
@@ -456,7 +472,9 @@
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"y = (x + sp.pi)**2"
@@ -585,7 +603,9 @@
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np"
@@ -594,7 +614,9 @@
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x_vec = np.arange(0, 10, 0.1)"
@@ -603,7 +625,9 @@
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"y_vec = np.array([sp.N(((x + sp.pi)**2).subs(x, xx)) for xx in x_vec])"
@@ -643,7 +667,9 @@
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f = sp.lambdify([x], (x + sp.pi)**2, 'numpy') # 第一个参数是一个变量列表\n",
@@ -653,7 +679,9 @@
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"y_vec = f(x_vec) # 现在我们可以之间传入一个numpy数组而f(x)会被更有效地计算"
@@ -983,7 +1011,9 @@
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f1 = 1/((a+1)*(a+2))"
@@ -1044,7 +1074,9 @@
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f2 = 1/(a+2) + 1/(a+3)"
@@ -1280,7 +1312,9 @@
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x, y, z = sp.symbols(\"x,y,z\")"
@@ -1289,7 +1323,9 @@
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"f = sp.sin(x*y) + sp.cos(y*z)"
@@ -1480,7 +1516,9 @@
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"n = sp.Symbol(\"n\")"
@@ -1705,7 +1743,9 @@
{
"cell_type": "code",
"execution_count": 88,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"h = Symbol(\"h\")"
@@ -2087,7 +2127,9 @@
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"m11, m12, m21, m22 = sp.symbols(\"m11, m12, m21, m22\")\n",
@@ -2432,7 +2474,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 13
- 5
1_numpy_matplotlib_scipy_sympy/bokeh_tutorial.ipynb View File

@@ -25,7 +25,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from bokeh.plotting import figure \n",
@@ -353,7 +355,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from numpy import cos, linspace\n",
@@ -457,7 +461,9 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from bokeh.sampledata.autompg import autompg\n",
@@ -864,7 +870,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
@@ -885,7 +893,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 88
- 30
1_numpy_matplotlib_scipy_sympy/matplotlib_full.ipynb View File

@@ -21,7 +21,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# This line configures matplotlib to show figures embedded in the notebook, \n",
@@ -64,7 +66,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from pylab import *"
@@ -80,7 +84,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import matplotlib\n",
@@ -119,7 +125,9 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from pylab import *"
@@ -142,7 +150,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = np.linspace(0, 5, 10)\n",
@@ -494,7 +504,9 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"fig.savefig(\"filename.png\")"
@@ -510,7 +522,9 @@
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"fig.savefig(\"filename.pdf\", dpi=200)"
@@ -556,7 +570,9 @@
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ax.set_title(\"title\");"
@@ -574,7 +590,9 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ax.set_xlabel(\"x\")\n",
@@ -593,7 +611,9 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ax.legend([\"curve1\", \"curve2\", \"curve3\"]);"
@@ -611,7 +631,9 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ax.plot(x, x**2, label=\"curve1\")\n",
@@ -746,7 +768,9 @@
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Update the matplotlib configuration parameters:\n",
@@ -792,7 +816,9 @@
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Update the matplotlib configuration parameters:\n",
@@ -838,7 +864,9 @@
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"matplotlib.rcParams.update({'font.size': 18, 'text.usetex': True})"
@@ -874,7 +902,9 @@
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# restore\n",
@@ -1289,7 +1319,9 @@
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# restore defaults\n",
@@ -1527,7 +1559,9 @@
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"n = np.array([0,1,2,3,4,5])"
@@ -1743,7 +1777,9 @@
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import matplotlib.gridspec as gridspec"
@@ -1843,7 +1879,9 @@
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"alpha = 0.7\n",
@@ -1856,7 +1894,9 @@
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"phi_m = np.linspace(0, 2*np.pi, 100)\n",
@@ -1979,7 +2019,9 @@
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from mpl_toolkits.mplot3d.axes3d import Axes3D"
@@ -2182,7 +2224,9 @@
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from matplotlib import animation"
@@ -2191,7 +2235,9 @@
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# solve the ode problem of the double compound pendulum again\n",
@@ -2225,7 +2271,9 @@
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(5,5))\n",
@@ -4260,7 +4308,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#\n",
@@ -4277,7 +4327,9 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#\n",
@@ -4687,7 +4739,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline\n",
@@ -5337,7 +5391,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#\n",
@@ -5353,7 +5409,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Now, open an interactive plot window with the Qt4Agg backend\n",
@@ -5483,7 +5541,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.5.4"
}
},
"nbformat": 4,


BIN
1_numpy_matplotlib_scipy_sympy/random-matrix.npy View File


+ 7
- 3
2_knn/knn_classification.ipynb View File

@@ -336,7 +336,9 @@
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
@@ -495,7 +497,9 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# split train / test data\n",
@@ -586,7 +590,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


Loading…
Cancel
Save