So, for example, in an electrochemical cell, it would be possible to take the sodium ion, give back its electron, and convert it into a metallic sodium, take the chloride ion, remove its electron, and restore chlorine gas.
所以,例如一个电化学的电池,它可能带有钠离子,让它得到电子,把它变成金属钠,得到氯离子,让它失去电子,作为氯气储存。
It is going to give me back a tuple a collection of two things, and so check out the syntax.
它将给我返回一个数组或者系列的一对值,然后检查一下语法。
And then, they hand me that receipt and I sign for that receipt and then I give it back to them.
之后他们给我收据,然后我在上面签字,然后把收据交还他们。
As kids, as babies-- going back to the baby's scene, we give ourselves the permission to be human, we know that it's natural.
孩子和婴儿-,回到婴儿期,我们准许自己为人,我们知道那是自然的。
I thought we should give it to the guy at the back, who is the moral guy. Who is our moral guy at the back?
我觉得我们应该给后面的那个人,他看起来很老实,后面谁很老实啊
If i would go back in time and give myself one piece of advice as undergradute, it would be take pride in your decisions and hardwork, but not in your gifts.
如果时光倒流,我能为本科时期的我,提个建议的话,我会说,为自己作出的决定和勤奋工作,而不是自己的天赋感到骄傲。
It would drive us into such baroque circumlocutions and avoidances of the obvious to say, "Oh, social factors have nothing to do with this," that we might as well just sort of--not give the distinction up, because I think it's very important always to have it in the back of our minds.
它会给我们带来大量的冗余的表达,并且很明显,它和社会力量有很大关系“,我们会倾向于忽视这种区别,但是我们还是要重视这种区别,因为我觉得。
Z So it would be incorrect to try to assign this to a variable X or Y or Z, because it doesn't actually give me anything back.
这个是错误的,来赋值这个给变量X或Y或,因为它的确没有返回什么给我。
OK, says it says enter a float. I give it something that can be converted into a float, it says fine. I'm going to go back and run it again though. If I run it again, it says enter a float.
好了,看到他说输入一个浮点数,我输入它可以转换为浮点数的值,那没问题,我回过来再运行一遍,如果我再运行一遍。
I give it some character. It gives me back an integer representing. It looks weird.
我输入一些字符,程序返回给我一个整数的表示。
And those are two things that you'd like to do with every looping construct you write: you'd like to be able to assure yourself that they will always terminate, and then the second thing you'd like to do, is to assure yourself that it does give you back a reasonable answer.
就是现在我有了能去检查程序,是不是做了正确的操作的能力:,这就是你们在写每个循环程序的时候,都要注意的两个事情:,第一件事情是要确保程序可以终结,第二件你要做的事情,就是要确保程序返回了正确的答案。
Computing square root. I'm going to capture it in a piece of code, I'm going to be able to refer to it by a name, and I'm going to suppress the details, meaning inside of that computation, you don't need to know what it does. You just need to know, if I give it the right kind of input, it'll give me back an input that satisfies the contract that I set up.
比如计算平方根,我会用一段代码来说明,我将给它命名,并且忽略细节,意思就是在这一段计算过程中,你不用知道它做了什么,你只需知道,如果我进行了正确的输入,它将会给我符合条件的输出。
Now that's not a very realistic assumption and we are going to come back and challenge it at the end of semester, but this will be complicated enough to give us a lot of material in the next ten weeks.
这不是一个很符合实际的假设,在期末的时候我们再来推翻这个假设,但是就这个假设下的内容,就足够我们接下来的十个星期学的了
So I can similarly do this, which is going to look strange because it's going to give me the same value back out, but it actually did a slightly different thing.
我也可以通过类似的手段来达到这个目的,这看起来很奇怪,但是会返回相同的值,但是它的实现真的有点不同。
And in Python the expression is, operand, operator, operand, when we're doing simple expressions like this, and if I give it to the interpreter, it gives me back exactly what you'd expect, which is that value. OK?
在Python中表达式就是,运算对象,操作符,运算对象,当我们处理这样的简单表达式的时候,我把表达式传给处理器,处理器给我返回了我想要的结果,对不对?
And in fact, now let me ask those two questions about this piece of code. First question is, for what values of integers-- we're going to assume integers-- but for what values of x does this code terminate? And the second question is, for what values of x does it give me back the right answer?
实际上,让我关于这块代码问两个问题,第一个问题是,对于什么样的整数值,我们会假设是整数,对于x的什么值程序,会最终终止?第二个问题是,对于x的什么值程序,会返回正确答案?
应用推荐