6.00 Introduction to Computer Science and Programming lec2
来源:互联网 发布:逆袭网络剧第六集美拍 编辑:程序博客网 时间:2024/05/17 01:36
从这一课开始,6.00开始介绍Python相关的东西。第一步,自然是配好环境,即安装Python(2.x系列)和对应的IDLE。在Ubuntu中,Python是自带的,例如Ubuntu 12.10自带Python 2.7. IDLE的安装比较容易,使用sudo apt-get install idle即可安装。
如何开始学习一个面向对象的语言?这里涉及到一个问题,什么是面向对象程序的基础元素?6.00的答案是这样:
类型 -> 表达式 -> 控制 ->输入输出等
类型是一个决定性的元素,它赋予冷冰的10以意义,例如,0110 1100 0110 1111 0111 0110 0111 0101 按ASCII的规则解释为字符,则可以产生“love”这个美好的词。什么是类型?我认为类型是指数据的值域和可以对数据进行的操作。例如32bit的整型,定义了32个bit来表示自身,同时在语法上又规定了相应的操作。
在面向对象的程序设计中,类是一个最基础的概念,真正的面向对象程序语言,应该将所有的数据都划归到某个类中。
有了类之后,下一步就要使这些类相互合作,因此下一个概念就自然出来了:表达式。
表达式是指运算符与运算数的组合。
输入输出:输入输出一般不会在语言的核心中,往往以库的形式存在,例如C中大名鼎鼎的printf。为什么新学语言时就学习输入输出库呢?自然是因为我们希望能立即获得一个“活”的程序,哪怕打印出个“hello world”,也会令新手心花怒放,还记得自己用C在dos中打出hello world时激动的心情,仿佛自己有了魔力:)
下面是Python相关的部分:
type(x) : 输出x的数据类型,如int, str, NoneType
print x or print(x): 输出x的值
raw_input('msg'): 获取用户输入
int(x): 将x转为int型数据
控制结构:
if expr :
statement
elif expr :
statement
else expr :
statement
whle expr:
statement
- 6.00 Introduction to Computer Science and Programming lec2
- 6.00 Introduction to Computer Science and Programming lec1
- 6.00 Introduction to Computer Science and Programming lec3 & lec4
- 6.00 Introduction to Computer Science and Programming lec6: Debugging
- 6.00 Introduction to Computer Science and Programming Lec 9: Set
- MIT《Introduction to Computer Science and Programming》: Testing and Debugging
- 【学习笔记】Introduction to Computer Science and Programming
- 6.00 Introduction to Computer Science and Programming Lec 8: Efficiency and Order of Growth
- 6.00 Introduction to Computer Science and Programming Lec 9: Lecture 9: Memory and Search Methods
- 6.00 Introduction to Computer Science and Programming lec5: Objects in Python
- 看后总结(Introduction to Computer Science and Programming,MIT 600)
- mit 6.00 introduction to computer science using Python video note
- Computer Science and Programming: Books and Resources
- Computer and Computer Science
- Mathematics for computer science-Introduction
- computer science and technology
- An Introduction to Asynchronous Programming and Twisted
- introduction to computation and programming using python
- 6.00 Introduction to Computer Science and Programming lec1
- 如何定制一款12306抢票浏览器——完结篇
- Android获取文件夹路径 /data/data/
- C++静态成员变量
- 二叉排序树
- 6.00 Introduction to Computer Science and Programming lec2
- xcode4.4+ APP 打包以及提交apple审核详细流程(新版本更新提交审核)
- 巧用头文件,多文件编译少发愁——也谈实用“StdAfx”
- appstore发布的问题no identities are available for signing
- 2013年2月19日发布“过年啰”总结
- 杭电acm 1.2.7 GPA
- 杭电 acm 1.2.8 Vowel Counting
- 过年啰 有米
- Silverlight中使用MVVM方式进行datagrid的内嵌combobox方法