iooops 发表于 2016-3-11 17:37:01

【Raspberry Pi入门系列3】PYTHON基础

筒子们我又来啦~~~

我又来分享我第三周的笔记啦~~~
这门课的名字叫The Raspberry Pi Platform and Python Programming for the Raspberry Pi~
详细地址戳这个:
https://www.coursera.org/learn/raspberry-pi-platform/home/week/3

啊我笔记原来用英文记的,懒得转换中文了……将就着看吧…………{:5_146:}

这一周讲到了Python。
首先为什么PYTHON这么适合为Raspberry Pi编程呢?
这是因为:PYTHON 提供很多的API,其中很多都很适合专门为树莓派编程,尤其是当其作为iOT设备的时候。

首先Python是high-level language,越高级的语言使用起来就越简单~~
convenient:
- no declaration of data types
- no pointers
- OOP(Object-oriented Programming)
but slow compared to C/C++:
- interpreted, not compiled

运行环境:
1. IDE(Integrated Development Environment) e.g. IDLE
    在Raspbian桌面上打开Menu - Programming - Python
2. Text editor and interpreter
    先去用text editor(sublime等)写一个test.py
    在terminal中输入:
<font size="2" face="微软雅黑">python test.py
</font>    然后就能运行啦。
由于第二种方式能用sudo获取最高权限,因此在某些情况下还是使用第二种方式更合适些。

执行方式:
1. Interactive: Python shell(IDLE/python in terminal)   对应运行环境中的IDE
2. Batch(批处理,比如先用sublime写,然后再运行.py文件)对应运行环境中的text editor和interpreter

下面是一些常用的表达式和数据类型:

Algebraic Expressions: +, - , *, /
Boolean Expressions: <, >, ==, !=……
Boolean Operators: and, or, not
Variables, Assignments(Variable types are not declared)
Strings      e.g. ‘Hello, world’
String Operators


Indexing Operator

Functions
输入:
<font size="2" face="微软雅黑">def test():
    print(‘hehe’)</font>(注意缩进!!!不然很有可能会出错)

使用(call the function):
<font size="2" face="微软雅黑">test()</font>Lists

List Methods

可以使用PYTHON运行下面的代码试试:
<font size="2" face="微软雅黑">1st =
lst.append(8)</font>Control Flow
一般就三种:if/for/while






以上就是PYTHON概览啦~~~~

筒子们可能会发现编程语言之间其实共同性还是特别多的。所以之前如果学过其他编程语言,比如C/C++/JAVA,大概就学下PYTHON的语法就行啦。

比较详细的PYTHON用法可猛戳下面的链接下载python_tutorial的PDF:
http://pan.baidu.com/s/1hrfu66g

当然还有很多资源可以利用,这里推荐RICE UNIVERSITY(饭大)在COURSERA上的PYTHON专项课程:
https://www.coursera.org/learn/interactive-python-1/home/welcome

iooops 发表于 2016-3-11 17:37:47

沙发是我的~~~~!!!

iooops 发表于 2016-3-11 17:37:58

板凳哈哈哈哈哈哈!!!!!

iooops 发表于 2016-3-11 17:38:22

地板{:5_122:}
占走!!!

dsweiliang 发表于 2016-3-12 08:17:26

来~{:5_173:}

iooops 发表于 2016-3-12 13:04:05

dsweiliang 发表于 2016-3-12 08:17
来~

{:5_153:}
页: [1]
查看完整版本: 【Raspberry Pi入门系列3】PYTHON基础