6.00 Introduction to Computer Science

                 and  Programming

• Goal:

–Become skillful at making a computer do what

you want it to do

– Learn computational modes of thinking

– Master the art of computational problem solving

What  does  a  computer  do?

• Fundamentally  a  computer:

– Performs  calculations

– Remembers  the  results

• What  calculations?

– Built  in  primitives

– Creating  our  own  methods  of  calculating

(最关键的事情是如何创造我们自己的计算方法、如何获取计算机一样的思考,也就是计算思维,然后按照这样的方式思考,以便计计算机能够提取它)

(计算思维模式意味着一切都可以看做是一个涉及到数字和公式的数学问题。)

Computational  problem  solving

• What is computation?

– What is knowledge?

– Declarative knowledge(陈述性知识)

• Statements of fact

– Imperative knowledge(程序性知识)

• “how to” methods or recipes

Declarative  knowledge

• “The square root of a number x is a number y such that y*y = x”

•Can you use this to find the square root of a particular instance of x?

(答案是不能,所以虽然陈述性知识是许多知识基石,但他不是我们所需要的)

Imperative knowledge

• Here is a “recipe” for deducing a square root Of a number x – attributed to Heron of

Alexandria in the first century AD

• Start with a guess, called g?

• If g*g is close enough to x, stop and say that g is the answer

• Otherwise make a new guess, by averaging g and x/g ?

• Using this new guess, repeat the process until we get close enough

(这就是程序性知识,寻找东西的方法)

How do we transform a recipe in a mechanical  process?

• Build a machine to compute square roots

  –Fixed Program Computers(固定程序计算机)

• Calculator

• Atanasoff and Berry’s (1941) computer for systems of linear equations

•Alan Turing’s (1940’s) bombe – decode Enigma codes

• Use a machine that stores and manipulates Instructions(能存储和操作命令)

 – Stored Program Computer

Stored  program  computer

• Sequence of instructions (program) stored inside computer

– Built from predefined set of primitive  instructions

• Arithmetic  and  logic

• Simple  tests

• Moving  data

• Special program (interpreter) executes(执行) eachinstruction in order

A  basic  machine  architecture

八根箭头代表着什么?

代码在内存中创造一套指令,这里有一个控制单元让我们按照指令顺序来执行,让数据通过ALU再回到内存中,有时还会执行测试指令跳转到代码的其他位置,它会一直不停做这些,直到OUTPUT最后果。

(Turing showed 6种原语就能计算任何计算,还能写一些代码序列创造新的原语,然后加入原语集中供整个系统使用。原语集是预先设定好的,在ALU中让计算机工作的组件)

Where  can  things  go  wrong?

• Syntactic errors(句法的错误)

– Common but easily caught by computer

• Static semantic errors(静态语义错误)

– Some languages check carefully before running,

others check while interpreting the program

– If not caught, behavior of program unpredictable

• Programs don’t have  semantic errors, but meaning may not be what was intended(意思   不明确)

– stops  running

– Runs  forever

– Produces an answer, but not programmer’s  intent(意图)

Our  goal

• Learn the syntax and semantics of a programming language

• Learn how to use those elements to translate “recipes” for solving a problem into a           form that the computer can use to do the work for us

• Computational modes of thought enable us to use a suite of methods to solve problems

Options for programming languages

•低级语言指令与control unit指令相似,能做到:

– Move data from one location to another

– Execute a simple ALU operation

– Jump to new point in sequence based on compare

• Checker confirms syntax static semantics correct

• Interpreter只能按序执行instruction

高级语言能执行更加抽象的术语:

–编译型语言多了一个编译器,将检查过的指令序列转化成我们需要的基本指令。

–解释型语言中有一种程序能将源代码转化成中间数据然后执行,不需要解释器,但每次只能对一条指     令进行转化和执行。

–编译型语言因为提前编译完成所有指令所以跑起来更快,但得在编译后的指令里去寻找实际指令中的     错误,十分困难。而解释型语言速度会慢点,但在准确知道错误发生时在代码的什么地方。

Iterative  code

• Branching structures (conditionals) let us jump to different pieces of code based on a       test

– Programs are constant time

• Looping structures (e.g., while) let us repeat pieces of code until a condition is satisfied

– Programs now take time that depends on values of variables, as well as length of            program

Loop characteristics(特征)

• Need a loop variable

– it is Initialized outside loop

– it Changes within loop

– Test for termination(结束) depends on variable

• Useful to think:

–性质是将一组程序变量映射到整数

定义一个函数使用另一个函数时的发现

•def程序遇到return时结束

•在环境框架中函数名和相应程序bond变量和值bond

•每一次调用新的函数都会创建一个新的框架,其中变量会为了调用进行局部bond

递归

•首先”递归步骤”,怎样才能使用已知的操作方法,将问题转化成一个更简单的版本。

•第二步,我们不能一直简化却解不开,所以要把计算它变得我们可以直接解决,这叫“基线条件”。

•也可以直接考虑“递归步骤”是什么,“基线条件”是什么

Debugging

•black box:找到一系列输入样本分类和预期输出

•white box:

—找到分支处,穷举路径并考虑边界情况;

—找到循环处,抽取循环没有未完成,完成了一次,完成了若干次三个案例使问题暴露

•conducting测试:首先单元测试,测试每个模块是否运行良好,抓算法编写错误;然后集成测试,整体的系统是否工作正常,抓模块交互错误。一直反复两个步骤。(基于黑盒和白盒)

•驱动测试:Exp print二分法检索发现变量和他们的值

OOP

•只考虑程序本身行为Everything is an object with type

•将对象看作被封装的数据抽象

将内部表示和访问接口分离

–接口定义了行为,隐藏了里面发生的事

•它会让我们聚焦对象,将它们作为基础的,原始的实体,然后思考我们如何操作它即可

•如果我们有了对象,我们需要为它创建实例,就是特定版本

•Advantages:

分而治之开发:每种类型的对象可以独立调试,而且降低了复杂度

代码编写更加容易,因为每建立一个新类我们会创建与之相关联的方法

定义一个类就会在内存中创建一个保存内部信息的新环境

能产生对象的特化,继承其基本行为,但也定义了新的行为

What do computer scientists do?

• They think computationally – Abstractions, algorithms, automated execution 他们运用抽    象将问题分解成许多片段,然后封装起来不用担心里面细节,只需考虑抽象的契约就可以了,给值得到    反回值;他们运用算法,通过一系列按顺序排列的步骤生成问题答案;把实际运行这一系列步骤的工    作交给自动执行的机器—求值器(处理问题的方式跟物理学家、生物学家、化学家,经济学家一样、    但和人文学家处理问题的方式却不同)

• Computational thinking will be a fundamental skill used by everyone

• Just like the three r’s: reading, ‘riting, and ‘rithmetic at last century  and  Now帮你对付   任何问题

Computational Thinking: the Process

• determine or invent useful abstractions – Suppressing details, formulating interfaces

给定一个问题要讲清楚,要找出问题的关键元素,以特殊方法确定它们—抽象表示我要描述的一个组    件,组件内部我或他人会构建细节来执行组件应该做的事。但抽象表示我可以通过压缩细节掩盖信息    表示我知道这个东西怎么工作.

这个步骤可能运行好几次,第一次解决问题时,我可能构建一个抽象集合,但应用时发现没有写对,    我可能要么添加另一个抽象,要么重写某个特定抽象的接口.

• Formulate solution to a problem and make a computational experiment(计算实验)

• Design and construct a sufficiently efficient implementation of experiment

不必花太多时间创建它可能造成不必要的损失,有许多不同的方式推出效率等级

• Validate experimental setup (i.e., debug it)

测试它的每一个单元,测试它的整体,确保满足不同边界条件或特殊用例,确保整个系统可以工作

• Run experiment

• Evaluate(评估) results of experiment保证得到的结果有意义

• Repeat as needed通过测试可能暴露出那些与我预期相驳论的地方,可能需要循环好几次才能重新    定义或设计计算试验中要实际应用什么

The three A’ s of computational thinking

• Abstraction

– 用好方法来设计抽象,这就要理解问题中的边界是什么,它将哪些东西分开了

– 操作可能涉及多层抽象

– clear the relationships the between layers(抽象)

• Automation

– Think in mechanizing our abstractions

– Mechanization is possible

• Because we have precise and exacting notations and models我们有精确严格的标记和模型

• There is some “machine” that can interpret our notations (in the computer)

• Algorithms

– A Language for describing automated processes

– 也可以用来构造抽象细节

Where have you been?

• Four major topics (and a language)

1. Learning a language for expressing computations – Python

2. Learning about the process of writing and debugging a program – Be systematic

3. Learning to estimate computational complexity

4. Learning about the process of moving from a problem statement to a computational          formulation of a method for solving the problem – Use abstraction

5. Learning a basic set of recipes – Algorithms

Why Python?

• Relatively easy to learn and use – Simple syntax

– Interpretive, which makes debugging easier

– Don’t have to worry about managing memory

• Modern

– Supports currently stylish mode of programming, object-oriented

• Increasingly popular

– Used in an increasing number of subjects at MIT and elsewhere

– Increasing use in industry

– Large and ever growing set of libraries

我只想建议你,希望你拥有的第一件宝物就是一辈子用计算思维进行思考

Where are you headed?

• There are other CS courses for which you are now prepared – Second part of 6.00

– optimization, modeling, simulation

– Introductory algorithms and data structures

– Introduction to artificial intelligence

– Software engineering

– Computer architecture

************************get箭袋里的新剑#**************************

6.00.1x Introduction to computation的更多相关文章

  1. MITx: 6.00.1x Introduction to Computer Science and Programming Using Python Week 2: Simple Programs 4. Functions

    ESTIMATED TIME TO COMPLETE: 18 minutes We can use the idea of bisection search to determine if a cha ...

  2. edX MITx: 6.00.1x Introduction to Computer Science and Programming Using Python 课程 Week 1: Python Basics Problem Set 1 Problem 3

    Assume s is a string of lower case characters. Write a program that prints the longest substring of  ...

  3. CS100.1x Introduction to Big Data with Apache Spark

    CS100.1x简介 这门课主要讲数据科学,也就是data science以及怎么用Apache Spark去分析大数据. Course Software Setup 这门课主要介绍如何编写和调试Py ...

  4. CS190.1x Scalable Machine Learning

    这门课是CS100.1x的后续课,看课程名字就知道这门课主要讲机器学习.难度也会比上一门课大一点.如果你对这门课感兴趣,可以看看我这篇博客,如果对PySpark感兴趣,可以看我分析作业的博客. Cou ...

  5. 2015/8/9 到家了,学完了CodeCademy的Python

    昨天坐了20多个小时的硬座回家.发现在网络信号差的火车上也是学习的好地方.如果你的手机电量不足的话,带上两本书简直是绝配.我在火车上阅读了两百多页的内容,并没有多大的疲累,那样无聊的环境里面能看书学习 ...

  6. Monty Hall悖论

    Monty Hall悖论又称为蒙提·霍尔悖论.三门问题.Monty Hall是上个世纪60年代,电视游戏节目“Let's Make a Deal”的主持人,这个悖论便是以他的名字来命名的.节目的规则是 ...

  7. 转 python trace walk DEMO

    https://blog.csdn.net/steadfast123/article/details/46965125 #quote from 'introduction to computation ...

  8. [CS充实之路] CS50 WEEK 1

    前言 大学电子专业,幸好自学了JAVA,遂有幸工作了三年,但这期间一直在焦虑,一个是基础不扎实的担心,另一个是未来方向的不确定.去年开始终于下定决心,一方面走一遍CS之路,巩固知识体系,另一方面部署自 ...

  9. IEEE 754 浮点数加减运算

    电子科技大学 - 计算机组成原理 小数的十进制和二进制转换 移码 定义:[X]移 = X + 2n ( -2n ≤ X < 2n ) X为真值,n为整数的位数 数值位和X的补码相同,符号位与补码 ...

随机推荐

  1. Ibatis教程

    Ibatis教程 |字号     转自:http://blog.csdn.net/lhminjava/article/details/1871136 ibatis 开发指南ibatis Quick S ...

  2. 【poj解题】1028

    stack的应用 #include<iostream> #include<stack> #include<stdio.h> #include<stdlib.h ...

  3. 我的云服务之WWW

    云服务器系统是:[root@ip-172-31-27-132 system]# cat /etc/redhat-release Red Hat Enterprise Linux Server rele ...

  4. jsp显示计算数值, 四舍五入

    <script>document.write(Math.round(<%= rs_MFM.getInt("PVRCompl") %>/<%= rs_M ...

  5. Xcode 6配置里定义${ARCHS_STANDARD}为armv7, arm64以及错误

    转发:http://www.cocoachina.com/ios/20141013/9897.html 最近一次的Xcode 6更新默认不再支持arm7s架构,究竟是要废除不用呢还是仅仅只是一个疏忽? ...

  6. 手机访问pc网站,自动跳转到手机网站

    <script type='text/javascript'> var browser = { versions: function () { var u = navigator.user ...

  7. nexus 中央仓库

    nexus 中央仓库 下载地址:http://www.sonatype.org/nexus/archived 下载最新版本 mkdir -p /opt/local/nexus tar zxvf nex ...

  8. CentOS 6.4 x64 Cacti 监控安装配置

    Cacti 监控安装配置   环境:   安装Cacti 的服务器   Linux 6.4 x64   ip 10.8.8.11     一: 配置iptables , selinux     vi ...

  9. 微信小程序一些简单的快捷键

    常用快捷键 格式调整 Ctrl+S:保存文件Ctrl+[, Ctrl+]:代码行缩进Ctrl+Shift+[, Ctrl+Shift+]:折叠打开代码块Ctrl+C Ctrl+V:复制粘贴,如果没有选 ...

  10. 顽强的的砂锅之——深究finally代码块与return语句的执行顺序!

    当问到finally代码块的执行顺序,就算刚刚学编程的小白都能毫不犹豫的说出答案:不管异常发生与否,finally语句块的代码一定会被执行!大体上这样讲是没有错,但是finally块中的代码一定会有效 ...