MIT 6.001X 2016 (1)introduction of Python

之前学的是学堂在线的MIT 6.001X 虽然有中文字幕翻译,但可惜用的是python2.7,学到第6个lecture,实在受不了,所以改学edx的16版,虽然全英文,但是也正好锻炼一下英语。

declarative knowledge: 陈述性知识,陈述事实 

imperative knowledge:规则性知识, 'how to' methods ,怎样去计算

aspects of language 

1.syntax(语法)  :determines whether a string is legal  e.g. in English ' I good '  就是一个语法错误

2.static semantics(静态语义):determines whether a string has meaning  e.g. 'i are good' 静态语义错误

3.semantics (全语义): assigns a meaning to a legal sentence  在程序语言中,一个句子只有一个意思,而在英语中,一个句子可能有很多意思。

scalar object:

int

float

bool  (True   False)

NoneType   (special and has one value:None)



float 变int   用int只会取整数部分  e.g. int(4.9) = 4 int(-4.9) = -4   

还有一种是round  四舍五入 当刚好是五 则 向偶数舍去  比如 round(2.5)  = 2    round(3.5) = 4

MIT 6.001X 2016 (1)introduction of Python_第1张图片


MIT 6.001X 2016 (1)introduction of Python_第2张图片

所以 -3 的2次方  要 (-3)**2  因为 假如是 -3**2 则因为**的运算顺序大于-  则结果是-9

floating point error:

float 型数字 可能会发生无法保存的完美在计算机中,因为计算机不能保存一个无限长的数据,所以一个无限长的数据会被近似保存,所以你最终的结果可能会和真正的结果有所不同。

计算机计算的顺序是按线性的 比如:

a = 1 
b = a + 1 
a = 2 

b 的值还是2 ,因为等到a=2 的时候 ,b的值已经先算出来了。


operation of boolean types: not  and  or 

操作顺序: 1. not

                 2. and

                  3. or


Python运算符优先级

以下表格列出了从最高到最低优先级的所有运算符:

运算符 描述
** 指数 (最高优先级)
~ + - 按位翻转, 一元加号和减号 (最后两个的方法名为 +@ 和 -@)
* / % // 乘,除,取模和取整除
+ - 加法减法
>> << 右移,左移运算符
& 位 'AND'
^ | 位运算符
<= < > >= 比较运算符
<> == != 等于运算符
= %= /= //= -= += *= **= 赋值运算符
is is not 身份运算符
in not in 成员运算符
not or and 逻辑运算符


你可能感兴趣的:(MIT,6.00.1.X,学习笔记,学习笔记)