• What happens now after we've executed this third line of code, what happens next in the story?

    执行完第三行代码会发生什么呢,在这之后会发生什么呢?

    哈佛公开课 - 计算机科学课程节选

  • And they're awfully simple because, all I can do now, is decide whether to execute some piece of code or another.

    它们之所以太简单的原因是:,现在我能做的,就是,决定执行一块代码或者执行另外一块。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • It ultimately evaluates that line of code but just once the stuff inside the curly braces, but the semicolon on the end, essentially has the effect of this.

    它最终执行了那行代码,但是只有一次,当那个东西在花括号里,分号放在后面,本质上影响了这个循环。

    哈佛公开课 - 计算机科学课程节选

  • And the robot or the computer or what have you is just automatically, mechanically following the code commands of the program.

    那些机器人,或叫做计算机等等,只是自动地,机械地执行程序的命令代码

    耶鲁公开课 - 死亡课程节选

  • So the open curly brace followed by the closed curly brace means everything inside of these curly braces should get executed, but only if that first condition is actually true.

    所以左花括号后面跟着,右花括号,这意味着花括号里面所有的代码,都应该是要被执行的,但只有当第一个条件是正确的。

    哈佛公开课 - 计算机科学课程节选

  • We could certainly implement this much more efficiently by just writing this one line of code, but, again, the key here is to take this step toward decomposing our code into chunks of code.

    我们可以写这一行代码,使代码执行更有效率,但是,这个关键字用来把我们的代码分解,成一段段的。

    哈佛公开课 - 计算机科学课程节选

  • You can say if this is true, then go and do the following pieces of code or puzzle pieces that are inside this part of the block, else go ahead and do these that are down here.

    你可以说如果条件成立,执行下面的代码段,或板块中的拼图,否则跳过去执行这下面的语句。

    哈佛公开课 - 计算机科学课程节选

  • And I want to remind you, that block of code is a set of instructions, the same set of instructions that are going to be done each time through the loop.

    我想提醒大家,这块代码是一个指令集,一个每次循环都会被执行的相同指令集,会变化的仅仅是变量的值。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • If you want to make sure both conditions are true and they both have to be true for any code to be executed, use ampersand ampersand.

    如果你想保证两个条件都成立,或者它们两个都必须为真值,才能执行一些代码,那就使用“&&“

    哈佛公开课 - 计算机科学课程节选

  • - So double bar means if this condition or this one -- and maybe even both -- are true, go down this road and execute that code.

    所以复纵线意思是,如果这两个条件之一-,或者两个都--是成立的,那就继续,执行后面的代码

    哈佛公开课 - 计算机科学课程节选

  • People make really stupid decisions and so as you know in this course with P sets there are three axes that we look at when evaluating your code.

    人们做了一个愚蠢的决定,在这个课程上,通过习题集,当执行你的代码的时候,有三个评估方面。

    哈佛公开课 - 计算机科学课程节选

  • And of course, you know, when you look at code it doesn't pause in between them.

    当然,你们知道的,在代码执行的时候不会暂停。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Now I have the ability to create a loop, that is, to reuse the same pieces of code over and over again as I go around.

    现在我们已经学会如何创建循环了,也就是,重复的一遍又一遍的,执行同一片代码

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • What I mean by that is, pick a simple set of values, and let's walk through it to see what happens. And this is useful because it's going to allow me to A make sure that I've got something that's going to terminate, it's going to let me make sure that in fact I'm doing the right kinds of updates.

    原因你们知道的,好,模拟代码,我的意思就是,选出一系列的值来,然后模拟下代码执行来看看结果,这很有用因为这让我确保我的程序在某个地方,可以终止,还会让我确保实际上我。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Having reached the end of the block, go back up and check the test.

    执行到了这块代码的最后,程序会回去再做一次测试。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So in your mind, if you are now the computer program and you are executing this thing from top to bottom, what just has happened verbally is we are stepping into the line of code that says sort left half of elements.

    在你们看来,如果你现在是计算机程序,正在从上到下执行一系列指令,刚才所发生的就是我们现在已执行到了这行代码,它告诉你要对左半部分的元素排序。

    哈佛公开课 - 计算机科学课程节选

  • So we've embedded some error checking, if you will, into our implementations.

    所以我们植入了一些错误校验,如果你愿意,在我们的执行代码里。

    哈佛公开课 - 计算机科学课程节选

  • If you find a matching sock which you didn't so then else.

    如果你找到相匹配的袜子就执行接下来的代码,否则就执行其他。

    哈佛公开课 - 计算机科学课程节选

  • This is code that's got to be executed before anything else happens.

    这个代码是,在所有事情发生之前执行的。

    哈佛公开课 - 计算机科学课程节选

  • There's nothing more that might get executed anyway.

    总之这里没有更多的代码需要执行了。

    哈佛公开课 - 计算机科学课程节选

  • And what it's saying semantically is, using that variable as my placeholder, have it walk through this collection, starting at the first thing, execute that code, then the next thing, execute that code, and so on.

    它的语义意思就是,把这个变量应用为我的占位符,用它来遍历这个集合,从第一个元素开始,执行代码,然后下一个元素,再执行代码

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Sorry? OK. You're doing the whole thing for me What's the complexity just of this inner loop m How many times do I go through that loop?

    就这一块代码的,我执行了多少次这个循环?,次对不对?,here?,Just,this,piece。,我一会儿就会去得到你的答案的?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • It takes an int; deal with it when you get to it and then once you look through the whole file, should you find -- ultimately find the actual code that defines or impliments this thing.

    它携带一个int数,当你获得了它就处理它,然后一旦你查看整个文件,最终你将发现实际代码中,定义或执行了这个东西。

    哈佛公开课 - 计算机科学课程节选

  • In Scratch you may have realized that, "I could implement my program this way with these puzzle pieces, but it kind of feels -- like I could use these puzzle pieces instead" -- that's absolutely the case in programming.

    在Scratch中你可能已经意识到,“我可以用这一段代码来,执行我的程序,不过这有点感觉到,我可以用这些代码段来代替“,那绝对是编程中的一个情况。

    哈佛公开课 - 计算机科学课程节选

  • So now, in this case, this code is going to, when we get here, check, and if you haven't seen that strange thing there, that exclamation point in bang computer-ese called a bang, it says x if ANS star ANS is not equal to x, all right?

    那么现在,在这个例子中,当我们执行到这里,代码会去检查,如果你没有看到过这个奇怪的东西,这个感叹号在计算机学中被叫做,代码的意思是如果ANS的平方不等于?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So it feels a little backward mentally perhaps, 1 but this is saying, "do this block of code as long as n is less than 1."

    所以它感觉可能有点迟缓,但是它指明,“只要n小于,执行这段代码

    哈佛公开课 - 计算机科学课程节选

  • So this line or these lines of code up here are arguably constant time steps to say if N is less than 2 in return, that it will always take maybe one step, maybe two steps, some number of fixed CPU cycles.

    如果N小于2并返回,那么这些行所对应的代码,通常只需要执行一步,或者两步,具体数字与CPU周期有关。

    哈佛公开课 - 计算机科学课程节选

  • So conceptually the key difference here, besides the syntax looking slightly different, it just means that if you want a chunk of code to execute no matter what initially, ; you can use the do while loop; if you want to check a condition first, you can use the while loop.

    所以概念上,则关键的区别是,除了语法看起来有点不同,它的意思是如果你想要一段代码,最初无论如何都要执行,你就可以用do,while循环;,如果你想要先检查条件,你可以用while循环。

    哈佛公开课 - 计算机科学课程节选

  • As an aside, if you ever just have one line of code that you want to execute, one puzzle piece in Scratch terminology, ; you actually don't need the curly braces; you only need the curly braces if you have two or more lines of code that you want to execute if that condition is true.

    此外,如果你只有一行代码,需要执行,在Scratch,术语中叫做,一句代码,你就不需要使用花括号了;,如果那个条件成立,你有两行或更多行的代码时需要执行时,你就需要花括号。

    哈佛公开课 - 计算机科学课程节选

  • But notice what this does. The first thing it does is, it says, let's check and make sure x is greater than or equal to 0. If it isn't, notice what's going to happen. None of that block is going to get executed, and it's going to come down here and print out a useful piece of information, which says, hey, you gave me a negative number. I don't know how to do this.

    做的是和以前一样的事情,但是注释它做了什么,第一件做的事情就是,程序说,要去检查并且确信x是大于等于0的,如果不是的话,请注意会发生什么,下面的代码都不会被执行,程序会到这里来然后显示一些有用的信息,信息会说,嘿,你给了我一个负数,我不知道该怎么弄这个了。

    麻省理工公开课 - 计算机科学及编程导论课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定