1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 麻省理工学院公开课:计算机科学及编程导论 课堂笔记

麻省理工学院公开课:计算机科学及编程导论 课堂笔记

时间:2021-12-26 22:06:33

相关推荐

麻省理工学院公开课:计算机科学及编程导论 课堂笔记

6.00

lecure1

skill goals:

1. computational thinking

2.read and write code

3.solve problem

think like a computational scientist

what is computaion?

python:三个维度来看:

high-level or low level language

general or targeted language

编译语言 or 解释语言

语法 syntax: what are legal expression in this language

语义 static semantics: what programs are meaningful

full semantics: what does the program meaning; what happen when running python

data

numbers

integer (INT)

floating point

strings

'abc'

表达式expression

3**5 次方;3/5=0;3.0/5浮点数;

为一个变量命名 value='eric' 绑定;

lecture 2

data

value and type

combine in expressions: ooperands and operators 运算符和运算对象

interpreter解释器 : evaluate and print

script 脚本: no print unless explict 除非我们让它这么做

str(3)+'abc' str: 变成字符串

type checking : weak or strong

4<'3' 没有报错,但是无意义

typing discipline 规范

运算前规定数据类型

9/5=1

9%%5=4

operate precedence操作优先 乘除>加减

when in double ,use parents括号

赋值 assignment 绑定binding 变量 linking to a 值

变量 variable X=3 used anywhere leghal

类型 is 动态的 X='ABC' 不要反复改变变量的类型

statements 声明 : legal commands that python can interpret

comments 注释 帮助reader理解代码的含义

变量名称的选择 : 评价是否优秀的代码 excluded key words

line programs : run one by one

branching programs : can change the order of instructions based on tests

: colon冒号 定义指令集/指令集的开始;回车意味着指令集的结束

x=15#把等号左边的值绑定到右边的变量

if (x/2)*2 ==x :#==判断左边的值是否等于右边

print 'even'

else: print 'odd'

if <some test> :

block of instructions

else:

block of instructions

if 可以嵌套

x=15

y=13

z=11

print x,y,z

if x<y:

if x <z : print 'x is least'

else:print'z is least'

else: print 'y is least'

#is this right?

if x<y and x<z: print 'x is least'# and ;or; not;

elif y<z: print 'y is least'# elif else if 简写

else: print'z is least'

计算复杂度-算法种类

iteration or loops 迭代 或者循环

y=0

x=3

itersLeft=x

while(itersLeft>0):y=y+x

itersLeft=itersLeft-1

#求数的平方

print y

循环内必须有会变化的量

写代码前一定要搞清楚对输入值的期望

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。