MIT 计算机科学及编程导论课程笔记--课程目标,数据类型,运算,变量

Skills:1.Computational thinking to write small scale programs

          2.the ability to use a vocabulary of computational tools in order to be able to understand programs written by others

          3.understand the fundamental both capabilities and limitations of computations

And the costs associated with them

 

          4.take a description of a problem and map it into something computational

 

Think like a computer scientist:the ability to think in computational models of thought

Sepsrsting out the mechanism,which is the computer from computational thinking.for example,knowledge are declarative and imperative knowledge.Imperative knowledge is about of how to deduce something.

How do I build a mechanical process to capture that set of computations?

Fixed-program computers meaning that they had a piece of circuitry designed to do a specific computation.

扫描二维码关注公众号,回复: 5344080 查看本文章

Canculator:it's basically anexample of a fixed-program computer.

Atanasoff:it basically solved linear equations.

Turing bombe:break German Enigma codes

We want to capture this idea of problem solving.So even within this framework of given a descripton of a computation as a set of steps ,in the idea that I could build a circuit to do it.L et me suggest for you what would be a wonderful circuit to build.

Suppose you could build a circuit with the following property:the input to this circuit would be any other circuit diagram.Given it a circuit diagram for some computation,you give it to the circuit,and that circuit would wonderfully reconfigure itself to act like the circuit diagram.

So what would that circuit look like?You can imagine these tiny little robots wandering around.pulling wirs and pulling out components and stacking them together.How would you build a circuit that could take a circuit diagram in and make a machine act like that circuit?

I want a machine that can take a recipe,the descirtion of a sequence of steps,take that as input,and then that machine will now act like what is described in that recipe.Reconfigure itself,emulate it,however you want to use the words,it's going to change how it does the computation.such a the intepreter.it's the basic heart of every computer.What it is doing ,is saying ,change the game.This is now an example of a stored-program computer.In a stored-program computer,is that I can provide to the computer a sequence of instructions describing the process I want it to execute.And inside of the machine,there in a process that sequence to be executed as described in that recipe.

In the computer,we have a memory,it's connected to two things;control unit,in what's called an ALU,an arithmetic logic unit,and this can take in input,and spit out output,and inside this stored-program computer,yoou have the following,you have a sequence of instructions.All these all get stored in there.Notice the difference.The recipe,the sequence of instructions,is actually to be read and it's treated just like data.It's inside the memory of the machine,which means we have access to it,we can change it,we can use it to build new pieces of code,as well as we can interpret it.one other piece that goes into this computer ,I'll put it separate ,you have a thiing called a program counter,and here is the basis of the computation.That program counter points to some location in memory  typically to the first instroction in the sequence .These instructions takes the value out of two places in memory,and run them through the multiplier in here,a little piece of circuitry,and stick them back into someplace in memory.Or take this value out of memory,run it through some other simple operation,stick back it in memory.Having executed this intruction,that counter goes up by one and we move to the next one.we executed that instruction,we move to next one.Some of those instructions will involve tests:and if the tests is true,it will change the value of this program counter to point to some other place in the memory,some other point in that sequence of instructions,and you will keep the process.Eventually you will hope to stop,and a value ges spit out, you're done.That's the heart of a computer.

The  process to control it is intriguing and interesting ,but the heart of the omputer is simply this notion that we build our description ,our recipes,on a sequence of primitive instructions.And then we have a flow of control.

And that flow of control is what I just described.It's moving through as a sequence of instructions,occasionally changing where we are as we move around.

Recipe is just a program .

What are the right primitives to use?Assuming I have a set of primitive instructions that I can describe everything on.Do a sequence of things.Given a fixed set of primitives.

Alan Turing:showed that with six simple primitives,anything coule be described in a mechanical process,It's actually arithmacally,to be programmed just using those six primitives.It says,anything you can do in one programming language ,you can do in another programming language.And there is no programming language that is better.

It's called Turing compatibility.

 

How to do things in modelss in  python.

1.whether this is a high-lever or low-lever language.that basically says how close are you the guts of the machine?A low level llanguage we used to call this assembly programming,you are doen at the  level of ,your primitives are literally moving pieces of data from one location of memory to another,through a very simple operation.a high level language,the designer has created a much richer set of primitive things.I n a higher level language,aquare root might simply be a primitive that we can use rather than you having to go over and code it.

2.what is the language general versus a targeted language?I'd argue that MATLAB is abasically a targeted language .

3.whether this is an interpreted versus a compiles language.What that basically says is the following: in an interpreted language,you take what's called the source code,the thing you write,it may go through a simple checker but it basically goes to the interpreter that thing inside the machine that's going to control the flow of going through each one of the flow,and give you an output.IN a compiled language,you have an intermediate step,in which you take the source code,it runs through what's called a checker or a compiler or both,and it creates what's called object code.it helps you catch bugs in your code,and convert it to a more efficent sequence of intructions before you actually go off and run it.

Syntax basically says,what are the legal expression in the language?

Static semantics:which programs are meaningful?which expression makes sense?

Full semantics:what does the program mean?what will happen when I run it?

You need to have a style.

Numbers:

Strings-type

Mingming:assign or bind to that name the value of the following expressioon.I can mow refer to that just by its name.that means take mystring and add to it the string,mylastname,

猜你喜欢

转载自blog.csdn.net/weixin_43218659/article/details/87970304