diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..96497c7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/tulingxueyuan.iml b/.idea/tulingxueyuan.iml new file mode 100644 index 0000000..6711606 --- /dev/null +++ b/.idea/tulingxueyuan.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..2127324 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,104 @@ + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1517360801979 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/.ipynb_checkpoints/03-\345\255\227\347\254\246\344\270\262+\345\217\230\351\207\217-checkpoint.ipynb" "b/.ipynb_checkpoints/03-\345\255\227\347\254\246\344\270\262+\345\217\230\351\207\217-checkpoint.ipynb" new file mode 100644 index 0000000..ba60c1c --- /dev/null +++ "b/.ipynb_checkpoints/03-\345\255\227\347\254\246\344\270\262+\345\217\230\351\207\217-checkpoint.ipynb" @@ -0,0 +1,352 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# 字符串\n", + " - 转义字符\n", + " - 格式化\n", + " - 内建函数\n", + " \n", + "## 转义字符\n", + " - 在不同的操作系统中对回车换行有不同的规定\n", + " - Windows: \\n\n", + " - Linux: \\r\\n\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 4)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m4\u001b[0m\n\u001b[0;31m s = 'let\\ 's go' #\\后面有一个空格,就报错了\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "是 = 'let\\'s go'\n", + "print(是)\n", + "\n", + "s = 'let\\ 's go' #\\后面有一个空格,就报错了\n", + "print(s)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I love \r\n", + " WuDang\n" + ] + } + ], + "source": [ + "print(\"I love \\r\\n WuDang\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 字符格式化\n", + " - 两种方法\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "i love wuda\n" + ] + } + ], + "source": [ + "print(\"i love %s\"%\"wuda\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "18\n", + "i am cp ,age 18\n" + ] + } + ], + "source": [ + "age = \"%d\"\n", + "print(age%18)\n", + "\n", + "print(\"i am %s ,age %d\"%(\"cp\",18))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### format函数格式化\n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "i love wudan\n", + "i love wudan,she's 18 years old\n" + ] + } + ], + "source": [ + "print(\"i love {}\".format(\"wudan\"))\n", + "print(\"i love {0},she\\'s {1} years old\".format(\"wudan\",18))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 表达式\n", + "## 算式运算符\n", + " 注意:Python 没有自增自减运算符" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4.333333333333333\n", + "4\n", + "1\n", + "27\n" + ] + } + ], + "source": [ + "a = 13 / 3\n", + "print(a)\n", + "b = 13 // 3\n", + "print(b)\n", + "c = 13%3\n", + "print(c)\n", + "\n", + "print(3**3) # ** 表示幂运算" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 比较运算符" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n", + "True\n" + ] + } + ], + "source": [ + "print(80==565)\n", + "print(80!=565)\n", + "print(80 == 80)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 赋值运算符" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "# = , 赋值\n", + "a = 0\n", + "c = a = 4\n", + "\n", + "# +=, 是缩写,\n", + "a = 0\n", + "a += 7 # a = a+ 7 的缩写\n", + "print(a)\n", + "\n", + "\n", + "# 所有数学运算符都有缩写形式\n", + "# -=, ×=, /=, //=, %=, **=,都是缩写形式" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## 逻辑运算符\n", + "- 对布尔值进行计算的符号\n", + "- and 逻辑与\n", + "- or 逻辑或\n", + "- not 逻辑非\n", + "- python中逻辑运算没有异或运算\n", + " - 运算规则:\n", + " - and看做乘法, or看做加法,\n", + " - True看做1, False看做0\n", + " - 则逻辑运算就能转换成整数数学运算\n", + " - 最后结果如果是0则为False, 否则为True\n", + " - 逻辑运算的短路问题\n", + " - 逻辑运算式,按照运算顺序计算,一旦能够确定整个式子未来的值,则不再进行计算,直接返回\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "a = True\n", + "b = True\n", + "c = False\n", + "print(a and c or b)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n" + ] + } + ], + "source": [ + "#短路运算\n", + "a = True or asdf\n", + "print(a)\n", + "\n", + "b = True or -43\n", + "print(b)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 成员运算符号\n", + "-用来检测某一个变量是否是另一个变量的成员\n", + " - in\n", + " - not in" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "l = [1,2,3,4]\n", + "bool = 5 in l\n", + "print(bool)\n", + "\n", + "bool = 5 not in l\n", + "print(bool)" + ] + } + ], + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git "a/.ipynb_checkpoints/04-\345\210\206\346\224\257\345\276\252\347\216\257-checkpoint.ipynb" "b/.ipynb_checkpoints/04-\345\210\206\346\224\257\345\276\252\347\216\257-checkpoint.ipynb" new file mode 100644 index 0000000..7dff73b --- /dev/null +++ "b/.ipynb_checkpoints/04-\345\210\206\346\224\257\345\276\252\347\216\257-checkpoint.ipynb" @@ -0,0 +1,47 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "if里面执行了\n", + "if外面执行了\n" + ] + } + ], + "source": [ + "age = 10\n", + "if age <17:\n", + " print(\"if里面执行了\")\n", + " \n", + "print(\"if外面执行了\")" + ] + } + ], + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git "a/.ipynb_checkpoints/05-while-\345\207\275\346\225\260-checkpoint.ipynb" "b/.ipynb_checkpoints/05-while-\345\207\275\346\225\260-checkpoint.ipynb" new file mode 100644 index 0000000..73de8b9 --- /dev/null +++ "b/.ipynb_checkpoints/05-while-\345\207\275\346\225\260-checkpoint.ipynb" @@ -0,0 +1,321 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hi\n" + ] + } + ], + "source": [ + "for i in range(1,10):\n", + " pass # 里面至少有一句,不然会报错\n", + "else:\n", + " print(\"hi\")" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n" + ] + } + ], + "source": [ + "i = 0\n", + "while i<5:\n", + " print(i)\n", + " i=i+1\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "你存入的本金:1000\n", + "你的在1年,本息共1067.0\n", + "你的在2年,本息共1138.489\n", + "你的在3年,本息共1214.767763\n", + "你的在4年,本息共1296.157203121\n", + "你的在5年,本息共1382.999735730107\n", + "你的在6年,本息共1475.6607180240242\n", + "你的在7年,本息共1574.5299861316337\n", + "你的在8年,本息共1680.023495202453\n", + "你的在9年,本息共1792.5850693810173\n", + "你的在10年,本息共1912.6882690295454\n", + "你的在11年,本息共2040.838383054525\n", + "你的钱在11年将翻倍\n" + ] + } + ], + "source": [ + "init = int(input(\"你存入的本金:\"))\n", + "s = 2 * init\n", + "y = 0\n", + "while init < s:\n", + " init = init * (1+0.067)\n", + " y +=1\n", + " print(\"你的在{0}年,本息共{1}\".format(y,init))\n", + "print(\"你的钱在%d年将翻倍\"%y)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 函数\n", + " - 函数的作用\n", + " - 函数的使用:\n", + " - 先定义\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "finished\n" + ] + } + ], + "source": [ + "def func():\n", + " print(\"function is worked\")\n", + "print(\"finished\")" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "function is worked\n" + ] + } + ], + "source": [ + "func()" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "我要对你说love you\n" + ] + } + ], + "source": [ + "def sayHi(what):\n", + " print(\"我要对你说%s\"%what)\n", + "sayHi(\"love you\")" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "love you\n" + ] + } + ], + "source": [ + "def func1():\n", + " return \"love you\"\n", + " print(\"会执行到这一步吗?\")\n", + "s = func1()\n", + "print(s)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 X 1 = 1 \n", + "2 X 1 = 2 2 X 2 = 4 \n", + "3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 \n", + "4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 \n", + "5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 \n", + "6 X 1 = 6 6 X 2 = 12 6 X 3 = 18 6 X 4 = 24 6 X 5 = 30 6 X 6 = 36 \n", + "7 X 1 = 7 7 X 2 = 14 7 X 3 = 21 7 X 4 = 28 7 X 5 = 35 7 X 6 = 42 7 X 7 = 49 \n", + "8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 \n", + "9 X 1 = 9 9 X 2 = 18 9 X 3 = 27 9 X 4 = 36 9 X 5 = 45 9 X 6 = 54 9 X 7 = 63 9 X 8 = 72 9 X 9 = 81 \n", + "-------between line---------\n", + "9 X 1 = 9 9 X 2 = 18 9 X 3 = 27 9 X 4 = 36 9 X 5 = 45 9 X 6 = 54 9 X 7 = 63 9 X 8 = 72 9 X 9 = 81 \n", + "8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 \n", + "7 X 1 = 7 7 X 2 = 14 7 X 3 = 21 7 X 4 = 28 7 X 5 = 35 7 X 6 = 42 7 X 7 = 49 \n", + "6 X 1 = 6 6 X 2 = 12 6 X 3 = 18 6 X 4 = 24 6 X 5 = 30 6 X 6 = 36 \n", + "5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 \n", + "4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 \n", + "3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 \n", + "2 X 1 = 2 2 X 2 = 4 \n", + "1 X 1 = 1 \n", + "-------between line---------\n", + " 1 X 1 = 1 \n", + " 2 X 1 = 2 2 X 2 = 4 \n", + " 3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 \n", + " 4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 \n", + " 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 \n", + " 6 X 1 = 6 6 X 2 = 12 6 X 3 = 18 6 X 4 = 24 6 X 5 = 30 6 X 6 = 36 \n", + " 7 X 1 = 7 7 X 2 = 14 7 X 3 = 21 7 X 4 = 28 7 X 5 = 35 7 X 6 = 42 7 X 7 = 49 \n", + " 8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 \n", + "9 X 1 = 9 9 X 2 = 18 9 X 3 = 27 9 X 4 = 36 9 X 5 = 45 9 X 6 = 54 9 X 7 = 63 9 X 8 = 72 9 X 9 = 81 \n" + ] + } + ], + "source": [ + "# 打印九九乘法表\n", + "def multi(r,c):\n", + " print(\"{0} X {1} = {2}\".format(r,c,r*c),end=\" \")\n", + " \n", + "def blank(n):\n", + " for i in range(1,n+1):\n", + " print(\" \".format(r,c,r*c),end=\" \")\n", + " \n", + "for r in range(1,10):\n", + " for c in range(1,r+1):\n", + " multi(r,c)\n", + " print()\n", + "\n", + "print(\"-------between line---------\")\n", + "for r in range(1,10):\n", + " for c in range(1,11-r):\n", + " multi(10-r,c)\n", + " print()\n", + " \n", + "print(\"-------between line---------\")\n", + "\n", + "for r in range(1,10):\n", + " blank(9-r)\n", + " for c in range(1,r+1):\n", + " multi(r,c)\n", + " print()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Help on built-in function print in module builtins:\n", + "\n", + "print(...)\n", + " print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n", + " \n", + " Prints the values to a stream, or to sys.stdout by default.\n", + " Optional keyword arguments:\n", + " file: a file-like object (stream); defaults to the current sys.stdout.\n", + " sep: string inserted between values, default a space.\n", + " end: string appended after the last value, default a newline.\n", + " flush: whether to forcibly flush the stream.\n", + "\n" + ] + } + ], + "source": [ + "help(print)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "550\n", + "8\n" + ] + } + ], + "source": [ + "def func(p1=10,p2=55):\n", + " print(p1*p2)\n", + "func()\n", + "func(2,4)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/.ipynb_checkpoints/note1-checkpoint.ipynb b/.ipynb_checkpoints/note1-checkpoint.ipynb new file mode 100644 index 0000000..c4785b9 --- /dev/null +++ b/.ipynb_checkpoints/note1-checkpoint.ipynb @@ -0,0 +1,282 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "12\n" + ] + } + ], + "source": [ + "print(12)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid character in identifier (, line 2)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m ‘’‘\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character in identifier\n" + ] + } + ], + "source": [ + "print(\"hello world\") # 打印helloworl\n", + "‘’‘\n", + " 中间的任何内容都是注释\n", + "‘’‘" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['False',\n", + " 'None',\n", + " 'True',\n", + " 'and',\n", + " 'as',\n", + " 'assert',\n", + " 'break',\n", + " 'class',\n", + " 'continue',\n", + " 'def',\n", + " 'del',\n", + " 'elif',\n", + " 'else',\n", + " 'except',\n", + " 'finally',\n", + " 'for',\n", + " 'from',\n", + " 'global',\n", + " 'if',\n", + " 'import',\n", + " 'in',\n", + " 'is',\n", + " 'lambda',\n", + " 'nonlocal',\n", + " 'not',\n", + " 'or',\n", + " 'pass',\n", + " 'raise',\n", + " 'return',\n", + " 'try',\n", + " 'while',\n", + " 'with',\n", + " 'yield']" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import keyword #查看关键字\n", + "keyword.kwlist" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 2 3\n" + ] + } + ], + "source": [ + "age1,age2,age3 = 1,2,3\n", + "print(age1,age2,age3)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "18\n" + ] + } + ], + "source": [ + "age = 0b10010\n", + "print(age)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.2\n" + ] + } + ], + "source": [ + "visionMeasure = .2\n", + "print(visionMeasure)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "19\n" + ] + } + ], + "source": [ + "#布尔值运算\n", + "age = 18 + True\n", + "print(age)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 字符串\n", + " - 如何表示\n", + " - 单引号\n", + " - 双引号\n", + " - 三引号" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "我爱lvoe\n", + "i chi ji\n", + "\n" + ] + } + ], + "source": [ + "html我 = '''\n", + "我爱lvoe\n", + "i chi ji\n", + "'''\n", + "print(html我)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "网\n" + ] + } + ], + "source": [ + "print('网')" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "网虫\n" + ] + } + ], + "source": [ + "print('网',end='')\n", + "print('虫')" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "please tell me your name:cp\n", + "cp\n" + ] + } + ], + "source": [ + "inp = input(\"please tell me your name:\")\n", + "print(inp)" + ] + } + ], + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git "a/03-\345\255\227\347\254\246\344\270\262+\345\217\230\351\207\217.ipynb" "b/03-\345\255\227\347\254\246\344\270\262+\345\217\230\351\207\217.ipynb" new file mode 100644 index 0000000..ba60c1c --- /dev/null +++ "b/03-\345\255\227\347\254\246\344\270\262+\345\217\230\351\207\217.ipynb" @@ -0,0 +1,352 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# 字符串\n", + " - 转义字符\n", + " - 格式化\n", + " - 内建函数\n", + " \n", + "## 转义字符\n", + " - 在不同的操作系统中对回车换行有不同的规定\n", + " - Windows: \\n\n", + " - Linux: \\r\\n\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 4)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m4\u001b[0m\n\u001b[0;31m s = 'let\\ 's go' #\\后面有一个空格,就报错了\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "是 = 'let\\'s go'\n", + "print(是)\n", + "\n", + "s = 'let\\ 's go' #\\后面有一个空格,就报错了\n", + "print(s)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I love \r\n", + " WuDang\n" + ] + } + ], + "source": [ + "print(\"I love \\r\\n WuDang\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 字符格式化\n", + " - 两种方法\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "i love wuda\n" + ] + } + ], + "source": [ + "print(\"i love %s\"%\"wuda\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "18\n", + "i am cp ,age 18\n" + ] + } + ], + "source": [ + "age = \"%d\"\n", + "print(age%18)\n", + "\n", + "print(\"i am %s ,age %d\"%(\"cp\",18))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### format函数格式化\n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "i love wudan\n", + "i love wudan,she's 18 years old\n" + ] + } + ], + "source": [ + "print(\"i love {}\".format(\"wudan\"))\n", + "print(\"i love {0},she\\'s {1} years old\".format(\"wudan\",18))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 表达式\n", + "## 算式运算符\n", + " 注意:Python 没有自增自减运算符" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4.333333333333333\n", + "4\n", + "1\n", + "27\n" + ] + } + ], + "source": [ + "a = 13 / 3\n", + "print(a)\n", + "b = 13 // 3\n", + "print(b)\n", + "c = 13%3\n", + "print(c)\n", + "\n", + "print(3**3) # ** 表示幂运算" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 比较运算符" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n", + "True\n" + ] + } + ], + "source": [ + "print(80==565)\n", + "print(80!=565)\n", + "print(80 == 80)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 赋值运算符" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + } + ], + "source": [ + "# = , 赋值\n", + "a = 0\n", + "c = a = 4\n", + "\n", + "# +=, 是缩写,\n", + "a = 0\n", + "a += 7 # a = a+ 7 的缩写\n", + "print(a)\n", + "\n", + "\n", + "# 所有数学运算符都有缩写形式\n", + "# -=, ×=, /=, //=, %=, **=,都是缩写形式" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## 逻辑运算符\n", + "- 对布尔值进行计算的符号\n", + "- and 逻辑与\n", + "- or 逻辑或\n", + "- not 逻辑非\n", + "- python中逻辑运算没有异或运算\n", + " - 运算规则:\n", + " - and看做乘法, or看做加法,\n", + " - True看做1, False看做0\n", + " - 则逻辑运算就能转换成整数数学运算\n", + " - 最后结果如果是0则为False, 否则为True\n", + " - 逻辑运算的短路问题\n", + " - 逻辑运算式,按照运算顺序计算,一旦能够确定整个式子未来的值,则不再进行计算,直接返回\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "a = True\n", + "b = True\n", + "c = False\n", + "print(a and c or b)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n" + ] + } + ], + "source": [ + "#短路运算\n", + "a = True or asdf\n", + "print(a)\n", + "\n", + "b = True or -43\n", + "print(b)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 成员运算符号\n", + "-用来检测某一个变量是否是另一个变量的成员\n", + " - in\n", + " - not in" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "l = [1,2,3,4]\n", + "bool = 5 in l\n", + "print(bool)\n", + "\n", + "bool = 5 not in l\n", + "print(bool)" + ] + } + ], + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git "a/04-\345\210\206\346\224\257\345\276\252\347\216\257.ipynb" "b/04-\345\210\206\346\224\257\345\276\252\347\216\257.ipynb" new file mode 100644 index 0000000..fc5e01f --- /dev/null +++ "b/04-\345\210\206\346\224\257\345\276\252\347\216\257.ipynb" @@ -0,0 +1,409 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "if里面执行了\n", + "if外面执行了\n" + ] + } + ], + "source": [ + "age = 10\n", + "if age <17:\n", + " print(\"if里面执行了\")\n", + " \n", + "print(\"if外面执行了\")" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sex:发\n", + "你的性别:发\n", + "发\n", + "坏女人\n", + "ending\n" + ] + } + ], + "source": [ + "sex = input(\"sex:\")\n", + "print(\"你的性别:{}\".format(sex))\n", + "print(sex)\n", + "if sex == \"男\":\n", + " print (\"好男人\")\n", + "else:\n", + " print(\"坏女人\")\n", + "\n", + "print(\"ending\")" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "ename": "IndentationError", + "evalue": "unexpected indent (, line 8)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m8\u001b[0m\n\u001b[0;31m print(\"error了\")\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unexpected indent\n" + ] + } + ], + "source": [ + "sex = input(\"sex:\")\n", + "print(\"你的性别:{}\".format(sex))\n", + "print(sex)\n", + "if sex == \"男\":\n", + " print (\"好男人\")\n", + "else:\n", + " print(\"坏女人\")\n", + " print(\"error了\")\n", + "print(\"ending\")" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 5)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m5\u001b[0m\n\u001b[0;31m else:\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "sex = input(\"sex:\")\n", + "print()\n", + "if sex == \"男\":\n", + " print (\"好男人\")\n", + " else:\n", + " print(\"坏女人\")\n", + " print(\"right了\") #同一个语句块内,缩进一致即可\n", + "print(\"ending\")" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "分数:101\n", + "------华丽的分割线-----\n", + "你上天了\n", + "ending\n" + ] + } + ], + "source": [ + "score = input(\"分数:\")\n", + "score = int(score)\n", + "print(\"------华丽的分割线-----\")\n", + "if score>100:\n", + " print (\"你上天了\")\n", + "elif score > 90:\n", + " print (\"优秀\")\n", + "elif score>80:\n", + " print (\"良好\")\n", + "elif score>70:\n", + " print (\"合格\")\n", + "else:\n", + " print(\"fuck\")\n", + "print(\"ending\")" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 1)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m scro> = \"df\"\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], + "source": [ + "scro> = \"df\"\n", + "print(scro>)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## python 中没有 switch-case 语句.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n", + "5\n", + "4\n" + ] + } + ], + "source": [ + "for score in [1,4,5,2,3,4]:\n", + " if score>3:\n", + " print(score) " + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6\n" + ] + } + ], + "source": [ + "for n in range(1,10):\n", + " if n == 6:\n", + " print(n)\n", + " break\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n", + "--\n", + "4\n", + "--\n", + "6\n", + "--\n", + "8\n", + "--\n" + ] + } + ], + "source": [ + "for _ in range(1,10):\n", + " if _ % 2 == 0:\n", + " print(_)\n", + " else:\n", + " continue\n", + " print(\"--\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## 习题课练习" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "*****\n", + "- - - - - \n", + "*****\n", + "- - - - - \n", + "*****\n", + "- - - - - \n", + "*****\n", + "- - - - - \n", + "*****\n", + "- - - - - \n" + ] + } + ], + "source": [ + "for _ in range(1,6):\n", + " print(\"*\" * 5)\n", + " print(\"- \"*5)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* cp* cp* cp* cp* cp\n", + "* cp* cp* cp* cp* cp\n", + "* cp* cp* cp* cp* cp\n", + "* cp* cp* cp* cp* cp\n", + "* cp* cp* cp* cp* cp\n" + ] + } + ], + "source": [ + "for _ in range(-1,4):\n", + " for _ in range(-1,4):\n", + " print(\"* \", end=\"cp\")\n", + " print()" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* * * * * \n", + "* * * * * \n", + "* * * * * \n", + "* * * * * \n", + "* * * * * \n" + ] + } + ], + "source": [ + "for _ in range(-1,4):\n", + " for _ in range(-1,4):\n", + " print(\"* \", end=\"\")\n", + " print()" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* * * * * \n", + "* *\n", + "* *\n", + "* * * * * \n" + ] + } + ], + "source": [ + "for i in range(4):\n", + " if i==0 or i ==3 :\n", + " print(\"* \" * 5)\n", + " else:\n", + " print(\"* *\")" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "* * * * * \n", + "* *\n", + "* *\n", + "* * * * * \n" + ] + } + ], + "source": [ + "for i in range(4):\n", + " if i==0 or i ==3 :\n", + " for i in range(5):\n", + " print(\"* \", end=\"\")\n", + " print()\n", + " else:\n", + " print(\"* *\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "for i in range(4):\n", + " if i==0 or i ==3 :\n", + " for i in range(5):\n", + " print(\"* \", end=\"\")\n", + " print()\n", + " else:\n", + " print(\"* *\")" + ] + } + ], + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git "a/05-while-\345\207\275\346\225\260.ipynb" "b/05-while-\345\207\275\346\225\260.ipynb" new file mode 100644 index 0000000..73de8b9 --- /dev/null +++ "b/05-while-\345\207\275\346\225\260.ipynb" @@ -0,0 +1,321 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hi\n" + ] + } + ], + "source": [ + "for i in range(1,10):\n", + " pass # 里面至少有一句,不然会报错\n", + "else:\n", + " print(\"hi\")" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "1\n", + "2\n", + "3\n", + "4\n" + ] + } + ], + "source": [ + "i = 0\n", + "while i<5:\n", + " print(i)\n", + " i=i+1\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "你存入的本金:1000\n", + "你的在1年,本息共1067.0\n", + "你的在2年,本息共1138.489\n", + "你的在3年,本息共1214.767763\n", + "你的在4年,本息共1296.157203121\n", + "你的在5年,本息共1382.999735730107\n", + "你的在6年,本息共1475.6607180240242\n", + "你的在7年,本息共1574.5299861316337\n", + "你的在8年,本息共1680.023495202453\n", + "你的在9年,本息共1792.5850693810173\n", + "你的在10年,本息共1912.6882690295454\n", + "你的在11年,本息共2040.838383054525\n", + "你的钱在11年将翻倍\n" + ] + } + ], + "source": [ + "init = int(input(\"你存入的本金:\"))\n", + "s = 2 * init\n", + "y = 0\n", + "while init < s:\n", + " init = init * (1+0.067)\n", + " y +=1\n", + " print(\"你的在{0}年,本息共{1}\".format(y,init))\n", + "print(\"你的钱在%d年将翻倍\"%y)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 函数\n", + " - 函数的作用\n", + " - 函数的使用:\n", + " - 先定义\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "finished\n" + ] + } + ], + "source": [ + "def func():\n", + " print(\"function is worked\")\n", + "print(\"finished\")" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "function is worked\n" + ] + } + ], + "source": [ + "func()" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "我要对你说love you\n" + ] + } + ], + "source": [ + "def sayHi(what):\n", + " print(\"我要对你说%s\"%what)\n", + "sayHi(\"love you\")" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "love you\n" + ] + } + ], + "source": [ + "def func1():\n", + " return \"love you\"\n", + " print(\"会执行到这一步吗?\")\n", + "s = func1()\n", + "print(s)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 X 1 = 1 \n", + "2 X 1 = 2 2 X 2 = 4 \n", + "3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 \n", + "4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 \n", + "5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 \n", + "6 X 1 = 6 6 X 2 = 12 6 X 3 = 18 6 X 4 = 24 6 X 5 = 30 6 X 6 = 36 \n", + "7 X 1 = 7 7 X 2 = 14 7 X 3 = 21 7 X 4 = 28 7 X 5 = 35 7 X 6 = 42 7 X 7 = 49 \n", + "8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 \n", + "9 X 1 = 9 9 X 2 = 18 9 X 3 = 27 9 X 4 = 36 9 X 5 = 45 9 X 6 = 54 9 X 7 = 63 9 X 8 = 72 9 X 9 = 81 \n", + "-------between line---------\n", + "9 X 1 = 9 9 X 2 = 18 9 X 3 = 27 9 X 4 = 36 9 X 5 = 45 9 X 6 = 54 9 X 7 = 63 9 X 8 = 72 9 X 9 = 81 \n", + "8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 \n", + "7 X 1 = 7 7 X 2 = 14 7 X 3 = 21 7 X 4 = 28 7 X 5 = 35 7 X 6 = 42 7 X 7 = 49 \n", + "6 X 1 = 6 6 X 2 = 12 6 X 3 = 18 6 X 4 = 24 6 X 5 = 30 6 X 6 = 36 \n", + "5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 \n", + "4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 \n", + "3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 \n", + "2 X 1 = 2 2 X 2 = 4 \n", + "1 X 1 = 1 \n", + "-------between line---------\n", + " 1 X 1 = 1 \n", + " 2 X 1 = 2 2 X 2 = 4 \n", + " 3 X 1 = 3 3 X 2 = 6 3 X 3 = 9 \n", + " 4 X 1 = 4 4 X 2 = 8 4 X 3 = 12 4 X 4 = 16 \n", + " 5 X 1 = 5 5 X 2 = 10 5 X 3 = 15 5 X 4 = 20 5 X 5 = 25 \n", + " 6 X 1 = 6 6 X 2 = 12 6 X 3 = 18 6 X 4 = 24 6 X 5 = 30 6 X 6 = 36 \n", + " 7 X 1 = 7 7 X 2 = 14 7 X 3 = 21 7 X 4 = 28 7 X 5 = 35 7 X 6 = 42 7 X 7 = 49 \n", + " 8 X 1 = 8 8 X 2 = 16 8 X 3 = 24 8 X 4 = 32 8 X 5 = 40 8 X 6 = 48 8 X 7 = 56 8 X 8 = 64 \n", + "9 X 1 = 9 9 X 2 = 18 9 X 3 = 27 9 X 4 = 36 9 X 5 = 45 9 X 6 = 54 9 X 7 = 63 9 X 8 = 72 9 X 9 = 81 \n" + ] + } + ], + "source": [ + "# 打印九九乘法表\n", + "def multi(r,c):\n", + " print(\"{0} X {1} = {2}\".format(r,c,r*c),end=\" \")\n", + " \n", + "def blank(n):\n", + " for i in range(1,n+1):\n", + " print(\" \".format(r,c,r*c),end=\" \")\n", + " \n", + "for r in range(1,10):\n", + " for c in range(1,r+1):\n", + " multi(r,c)\n", + " print()\n", + "\n", + "print(\"-------between line---------\")\n", + "for r in range(1,10):\n", + " for c in range(1,11-r):\n", + " multi(10-r,c)\n", + " print()\n", + " \n", + "print(\"-------between line---------\")\n", + "\n", + "for r in range(1,10):\n", + " blank(9-r)\n", + " for c in range(1,r+1):\n", + " multi(r,c)\n", + " print()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Help on built-in function print in module builtins:\n", + "\n", + "print(...)\n", + " print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n", + " \n", + " Prints the values to a stream, or to sys.stdout by default.\n", + " Optional keyword arguments:\n", + " file: a file-like object (stream); defaults to the current sys.stdout.\n", + " sep: string inserted between values, default a space.\n", + " end: string appended after the last value, default a newline.\n", + " flush: whether to forcibly flush the stream.\n", + "\n" + ] + } + ], + "source": [ + "help(print)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "550\n", + "8\n" + ] + } + ], + "source": [ + "def func(p1=10,p2=55):\n", + " print(p1*p2)\n", + "func()\n", + "func(2,4)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/note1.ipynb b/note1.ipynb new file mode 100644 index 0000000..c4785b9 --- /dev/null +++ b/note1.ipynb @@ -0,0 +1,282 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "12\n" + ] + } + ], + "source": [ + "print(12)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid character in identifier (, line 2)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m ‘’‘\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character in identifier\n" + ] + } + ], + "source": [ + "print(\"hello world\") # 打印helloworl\n", + "‘’‘\n", + " 中间的任何内容都是注释\n", + "‘’‘" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "scrolled": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "['False',\n", + " 'None',\n", + " 'True',\n", + " 'and',\n", + " 'as',\n", + " 'assert',\n", + " 'break',\n", + " 'class',\n", + " 'continue',\n", + " 'def',\n", + " 'del',\n", + " 'elif',\n", + " 'else',\n", + " 'except',\n", + " 'finally',\n", + " 'for',\n", + " 'from',\n", + " 'global',\n", + " 'if',\n", + " 'import',\n", + " 'in',\n", + " 'is',\n", + " 'lambda',\n", + " 'nonlocal',\n", + " 'not',\n", + " 'or',\n", + " 'pass',\n", + " 'raise',\n", + " 'return',\n", + " 'try',\n", + " 'while',\n", + " 'with',\n", + " 'yield']" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import keyword #查看关键字\n", + "keyword.kwlist" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 2 3\n" + ] + } + ], + "source": [ + "age1,age2,age3 = 1,2,3\n", + "print(age1,age2,age3)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "18\n" + ] + } + ], + "source": [ + "age = 0b10010\n", + "print(age)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.2\n" + ] + } + ], + "source": [ + "visionMeasure = .2\n", + "print(visionMeasure)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "19\n" + ] + } + ], + "source": [ + "#布尔值运算\n", + "age = 18 + True\n", + "print(age)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 字符串\n", + " - 如何表示\n", + " - 单引号\n", + " - 双引号\n", + " - 三引号" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "我爱lvoe\n", + "i chi ji\n", + "\n" + ] + } + ], + "source": [ + "html我 = '''\n", + "我爱lvoe\n", + "i chi ji\n", + "'''\n", + "print(html我)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "网\n" + ] + } + ], + "source": [ + "print('网')" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "网虫\n" + ] + } + ], + "source": [ + "print('网',end='')\n", + "print('虫')" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "please tell me your name:cp\n", + "cp\n" + ] + } + ], + "source": [ + "inp = input(\"please tell me your name:\")\n", + "print(inp)" + ] + } + ], + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/password.txt b/password.txt new file mode 100644 index 0000000..5928096 --- /dev/null +++ b/password.txt @@ -0,0 +1 @@ +ssh y 文件的密码:python diff --git a/y b/y new file mode 100644 index 0000000..dc38b94 --- /dev/null +++ b/y @@ -0,0 +1,30 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,FC3ABEC8FC4335E41CAF472DABB06328 + +3O50/UMqGrcl2dTTMd94INkfKNVprrUWehdZSysc0a4cAscy3ozk4cC8FYYeYJUA +Xl7ipDypvF2IqTrIaEzvUM3FPA4tO1BHFhQ2WUrDxJEjHphjd1XIjhYHssMGWSBG +IaT4Oy9wq/PTvNL4nGVYWNykpys8oNbDcKk0qYNqJcu03WUohWYnRTSDe2bwa1Hb +k1TgJZeKmC2z+AavYgNs02rPAbH5RF+Tw+Zswwuf4j9Kn0uK3fPte6fgfhY62gvk +UE8huBgn0IVPgXO8n2srWjnpqa7aYhqC7F/HWjDmEAryuNyizUfvRQOaQfcx7gwt +hLcbwEDD5de85uNJDIGOM93TOSTz/8vWRp6mFKNXOp2mgKSJ8sQ5h6CYX1g01x1U +HGjKn2O6KsKgDp4AwC+kczWvwZNSUVdnCAHC7FN4Qq+7dkTsETGN0uXD6xXxBZY4 +tQ5PSWvmgrlcjYcflk1XwAB2IZo732e56Zh3MfmaNt70/stsN1l5iXPtJv+wK4Cg +XYkB4TJGBEW4EQaoD3d3cBXi/64b7aCrdZMgYLx3Vm2M7zbx1KZHn98XbUKBimgT +Tgr6pHkNpda//JFteQ2vsE8PgGvMdWPUh7mu/YKNbwaiOIKFoDVyKt+k1qISJbhq +vvliJ9cBMa+3ZjW+CmKJUwuLNfuX55yE7vY2v2nCYqcmAwm80J3cPQW3ErUULSrd +nizo5y9LXbpaQdA37IKlZiEYBa6T86kBj+2QewrrlYCCb6JGrEC3BYtOkVad9xvi +PcAOfJZ1eUODhV1bYhwSz1LpxsIUQ2S/7PHdHGEd9gUr+/m+g/g/nLnzJp3usmOo +ADSMvrY13e2ou4tvyFfUEuVMm8hJar25kTCknTzS/b90JKNP2Xy1KAOMHjOrQD57 +tocThrnG7Wqu9i+yu8L1Y1GBmf270tEYp219YRJqLDXpN0yrzBhP3bZ77i6Td5o7 +q7spB+HNBZs6Z2yioVQ+6H1hcvk3dbD2Lj+SR3H8AqbT5Q+JGU3c+AXbvJ88LyTS +eeX7NrAEqhbHX7heb5x6gT4jzZ3jxKlhViL453Z2D5ovJb+cApcWZCwWmjYc6I3O +BKP9txzbmmwsYb0OS5hcyL7fy3rkjm9sQ/gtDtfFxHGI6RbSwhOu568mc2JmLShV +j+9eXvqEyz/6G3vjDVJfHTm09yZBuSrh5oW6xxC61WH5k03TWJ3jX0iUDP5VcSBB +Ct+UuCkqiBxuKDOpMA1PbfgI+8ZAlQ5YGA+kcaUhzicOHTvG3WpF5mKH+ekBHwFP +0fbi11kwfz/PMXn0vrwYkFdjINlxwOD8vbbzgbwFKqVGN3QP9lAeuwGw2lZVToFx +zOm/eYKnzHIckYcRyUKbT7TNU8yGihck+lOQhYKsrOaAguLNTUaTzaTgZ642hV/c +i7cZQELr2vmXqclI6aYOy2FeEVj9hE9tn3Ufa61JPkHEEHiCKH5g09pF7aXSq1al +fp66Upm7jwkvNXM4FOPro8bf/Xm1XZfShNy1cVURrE5xaI1P3AIzc72BWUx4BSdk +wdk7oMZ0Fkpm+H+pSqJgdmbB4KK47DqNPjmRQGo2ktsO9+qQrPqHHFydd7bzVcJL +-----END RSA PRIVATE KEY----- diff --git a/y.pub b/y.pub new file mode 100644 index 0000000..c2774d6 --- /dev/null +++ b/y.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKStl7ItLW0zbr/D8vARCLp7dfW+OkgdLbh5gMEqq9OmrYHe3zfVPHGMq2oSZYsuosdpGNBaSL38uTzh4+vk7Ax5zOvfZUTW9EQz7z6dLaibu7UNQu99JzCQmMAwQwQlffQyk8GQj+9hVA5CF7hCZVIFMbtlZZMGRmIeVAU95o1d5nmw0kkMyUq5DTV1JfjllYAYHzW69vfjp0quLsi/ufhTlAjppsksVrNFf0Py8y6L+X+/w01HV+stOA06EHShuc34crIueS5gfcq3vSbW5G8Ga2rhGI/IyHWyZdlfjuXNTInD4fLUdxBgJyuaT6v3ouSZXcSKDoCFwskWwcBYyp tlxy@augs