Browse Source

Update README / Install Python

master
bushuhui 2 years ago
parent
commit
16850b0ef5
7 changed files with 132 additions and 40 deletions
  1. +1
    -1
      0_python/0-ipython_notebook.ipynb
  2. +62
    -7
      0_python/1_Basics.ipynb
  3. +8
    -6
      0_python/2_Print_Statement.ipynb
  4. +49
    -17
      0_python/3_Data_Structure_1.ipynb
  5. +2
    -2
      0_python/README.md
  6. +5
    -5
      README.md
  7. +5
    -2
      references_tips/InstallPython.md

+ 1
- 1
0_python/0-ipython_notebook.ipynb View File

@@ -194,7 +194,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 62
- 7
0_python/1_Basics.ipynb View File

@@ -135,7 +135,9 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = 2\n",
@@ -170,7 +172,9 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = y = 1"
@@ -306,7 +310,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Python3版本之后,自动将整数的除法转换成浮点数,这样和人类的直觉比较一致。"
"**Note: Python3版本之后,自动将整数的除法转换成浮点数,这样和人类的直觉比较一致。**"
]
},
{
@@ -420,7 +424,9 @@
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"z = 1"
@@ -490,7 +496,9 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"a = 2 #10\n",
@@ -589,7 +597,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Python带有预先构建的函数"
"Python带有内置的函数,方便执行一些常用的操作。"
]
},
{
@@ -886,6 +894,53 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"类似的函数还有`type`"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"int"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(1)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"type"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(type)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**pow(x,y,z)** 可以被用来找到幂函数$x^y$也可以找到第三个指定数字的mod值,即:($x^y$ % z)。"
]
},
@@ -1004,7 +1059,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 8
- 6
0_python/2_Print_Statement.ipynb View File

@@ -13,17 +13,19 @@
"source": [
"`print` 是Python内置的一个函数,可以用下列不同的方式使用。\n",
"\n",
" - print(\"Hello World\")\n",
" - print(\"Hello\", <Variable Containing the String>)\n",
" - print(\"Hello\" + <Variable Containing the String>)\n",
" - print(\"Hello %s\" % <variable containing the string>)"
"```\n",
" print(\"Hello World\")\n",
" print(\"Hello\", <Variable Containing the String>)\n",
" print(\"Hello\" + <Variable Containing the String>)\n",
" print(\"Hello %s\" % <variable containing the string>)\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**需要注意的是,Python2中`print`是一个语句,但是在Python3变成函数,打印的内容需要用`()`括起来**"
"**注意: Python2中`print`是一个语句,但是在Python3变成函数,打印的内容需要用`()`括起来**"
]
},
{
@@ -606,7 +608,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 49
- 17
0_python/3_Data_Structure_1.ipynb View File

@@ -35,7 +35,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"a = []"
@@ -154,7 +156,9 @@
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"y = ['carrot','potato']"
@@ -505,7 +509,9 @@
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"names = ['Earth','Air','Fire','Water']"
@@ -588,7 +594,9 @@
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"mlist = ['bzaa','ds','nc','az','z','klm']"
@@ -623,7 +631,9 @@
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"nlist = ['1','94','93','1000']"
@@ -723,7 +733,9 @@
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"lst = [1,1,4,8,7]"
@@ -784,7 +796,9 @@
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"lst1 = [5,4,2,8]"
@@ -909,7 +923,9 @@
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"lst.insert(-1, 10)"
@@ -1259,7 +1275,9 @@
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"lista= [2,1,4,3]"
@@ -1340,7 +1358,9 @@
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"lista = [2,1,4,3]"
@@ -1472,7 +1492,9 @@
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"tup = ()\n",
@@ -1600,7 +1622,9 @@
{
"cell_type": "code",
"execution_count": 79,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"(a,b,c)= ('alpha','beta','gamma')"
@@ -1626,7 +1650,9 @@
{
"cell_type": "code",
"execution_count": 81,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"(c, b, a) = (a, b, c)"
@@ -1798,7 +1824,9 @@
{
"cell_type": "code",
"execution_count": 101,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"set1 = set([1,2,3])"
@@ -1807,7 +1835,9 @@
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"set2 = set([2,3,4,5])"
@@ -1950,7 +1980,9 @@
{
"cell_type": "code",
"execution_count": 97,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"set1=set([10, 9, 1, 2, 4])"
@@ -2047,7 +2079,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
"version": "3.5.4"
}
},
"nbformat": 4,


+ 2
- 2
0_python/README.md View File

@@ -3,12 +3,12 @@

Python 是一门上手简单、功能强大、通用型的脚本编程语言。

* Python 类库极其丰富,这使得 Python 几乎无所不能,网站开发、软件开发、大数据分析、网络爬虫、机器学习等都不在话下
* Python 类库丰富,这使得 Python 几乎无所不能,网站开发、软件开发、大数据分析、网络爬虫、机器学习等都不在话下
* Python最主要的优点是使用人类的思考方式来编写程序,大多数情况下使用封装好的库能够快速完成给定的任务,虽然执行的效率不一定很高,但是极大的缩短了程序设计、编写、调试的时间,因此非常适合快速学习、尝试、试错。

关于Python的安装可以参考[《安装Python环境》](../references_tips/InstallPython.md),或者自行去网络上查找相关的资料。

为方便大家学习本教程,我们提供了[《90分钟学会Python-在线视频》](https://www.bilibili.com/video/BV1Uz4y167xY/),请观看学习。
为方便大家学习本教程,我们提供了[《90分钟学会Python-在线视频》](https://www.bilibili.com/video/BV1oZ4y1N7ei?p=9),请观看学习。

![learn python](images/learn_python.jpg)



+ 5
- 5
README.md View File

@@ -77,13 +77,13 @@
## 2. 学习的建议
1. 为了更好的学习本课程,需要大家把[Python编程](0_python)能力培养好,通过一定数量的练习题、小项目培养Python编程思维,为后续的机器学习理论与实践打好坚实的基础。
2. 机器学习是一门应用、实践性质很强的学科,需要理论结合实践并在实际应用中进行学习。学习一门知识最好的办法就是使用它,因此建议读者一定要自己动手实操,不要嫌麻烦,尽可能把本书中的代码全部自己敲一下这样才能对内容有更加深刻的理解。
3. 本教材各个章节都有[作业](https://gitee.com/pi-lab/machinelearning_homework),此外还有[综合练习项目](https://gitee.com/pi-lab/machinelearning_homework),通过完成作业和练习项目来加深对所学知识的理解。
3. 本教材各个章节都有[作业](https://gitee.com/pi-lab/machinelearning_homework),此外还有[综合练习项目](https://gitee.com/pi-lab/machinelearning_homework),通过完成作业和练习项目来加深对所学知识的理解。
4. 每个课程前半部分是理论基础,后半部分是代码实现。如果想学的更扎实,可以自己把各个方法的代码亲自实现一下。做的过程如果遇到问题尽可能自己想解决办法,因为最重要的目标不是代码本身,而是学会分析问题、解决问题的能力。
5. 些同学看完数学公式后觉得理解了,可是要写程序时却不知如何下手,然后就会发现自己其实并没有完全理解。因此,编写程序是一种验证自己是否真正理解数学和理论的方法。另外,即使无法理解数学公式,通过运行别人编写好的程序(与数学公式对应且可运行的),并与公式相互验证、分析也可以帮助自己理解。
6. **不能直接抄已有的程序,或者抄别人的程序**,如果自己不会要自己去想,去找解决方法,或者去问。如果直接抄别人的代码,这样的练习一点意义都没有。**如果感觉太难,可以做的慢一些,但是坚持自己思考、自己编写练习代码**。
7. **请先遍历一遍所有的文件夹,了解有什么内容,资料**。各个目录里有很多说明文档,如果不会先找找有没有文档,如果找不到合适的文档就去网上找找。通过这个过程锻炼自己搜索文献、资料的能力。
5. 些同学看完数学公式后觉得自己理解了,可是要写程序时却不知如何下手,然后就会发现自己其实并没有完全理解。因此编写程序是一种验证自己是否真正理解数学和理论的重要方法。另外,即使无法理解数学公式,通过运行别人编写好的程序(与数学公式对应且可运行的),并与公式相互验证、分析也可以帮助自己理解。
6. **不能直接抄已有的程序,或者抄别人的程序**,如果自己不会要自己去想,去找解决方法,或者去问。如果直接抄别人的代码,这样的练习一点意义都没有。**如果感觉太难,可以做的慢一些,但是坚持自己思考、自己编写练习代码**。
7. **请先遍历一遍所有的文件夹,了解有什么内容,资料**。各个目录里有很多说明文档,如果不会,可先找找有没有相关的文档,如果找不到合适的文档就去网上找找。通过这个过程锻炼自己搜索文献、资料的能力。
8. 人的时间和精力是有限的,在目前学科大融合的背景下,各位同学不单单是学这一门课,还有很多专业课需要学习。即使最终理解并掌握了这门课,但如果花费了太多时间,那就耽误其他课程的学习。如果为了准备数学``装备”而从指数、对数、导数、矩阵、概率和统计等一一学起,那么光是这些就需要花费很长时间,很不现实。此外,在攀登机器学习这座高山时,假如你想把各种各样的方法和概念全都理解,那么你可能因为追寻绝佳景色的道路过于漫长而中途放弃。
9. 因此建议同学们先建立感性认识,虽然不是很全面,但是足以去解决一些实际问题,在解决问题的过程加深对理论、算法、编程、验证等方面的理解}。此外,尽可能在掌握基本知识的情况下就开始做习题、小项目,在做的过程去查资料,并不断完善自己的知识。尽可能采用循环迭代的方式去学习,不要强求自己一步就学会,而是在做、学的过程不断强化感性认识,并牵引理论学习。
9. 因此建议同学们先建立感性认识,虽然不是很全面,但是足以去解决一些实际问题,在解决问题的过程加深对理论、算法、编程、验证等方面的理解。此外,尽可能在掌握基本知识的情况下就开始做习题、小项目,在做的过程去查资料,并不断完善自己的知识和技能**尽可能采用循环迭代的方式去学习,不要强求自己一步就学会,而是在做、学的过程不断强化感性认识,并牵引理论学习。**
10. 本课程的练习题最好使用[《Linux》](https://gitee.com/pi-lab/learn_programming/blob/master/6_tools/linux)以及Linux下的工具来做。逼迫自己使用[《Linux》](https://gitee.com/pi-lab/learn_programming/blob/master/6_tools/linux),只有多练、多用才能快速进步。如果实在太难,先在虚拟机(建议VirtualBox)里装一个Linux(例如Ubuntu,或者LinuxMint等),先熟悉一下。但是最终需要学会使用Linux。




+ 5
- 2
references_tips/InstallPython.md View File

@@ -10,8 +10,11 @@

由于Anaconda集成了大部分的python包,因此能够很方便的开始使用。由于网络下载速度较慢,因此推荐使用镜像来提高下载的速度。镜像的使用方法可以参考:[Anaconda镜像的说明文档](https://mirrors.bfsu.edu.cn/help/anaconda/)

1. 在这里找到适合自己的安装文件,然后下载
https://mirrors.bfsu.edu.cn/anaconda/archive/
1. 在下列镜像网站找到适合自己的安装文件,然后下载
* https://mirrors.bfsu.edu.cn/anaconda/archive/
* https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
* https://mirrors.aliyun.com/anaconda/archive/
* https://mirrors.hit.edu.cn/anaconda/archive/

例如: https://mirrors.bfsu.edu.cn/anaconda/archive/Anaconda3-2020.11-Windows-x86_64.exe



Loading…
Cancel
Save