Well if I-- you know, with let me say it differently. I don't need to worry about how checking is done, it's handled inside of that function.
好,如果你们知道,抱歉,让我们换种说法,我不必担心检查工作,是则会么做的,这是在方法体内部进行的。
So if in fact I wanted to make sure this was a number, I should have done something like either try and convert it to a number, which of course failed here, or put in a check to say where it is.
因此实际上如果我想确保,这是一个数字的话,我们的课程上的代码,在这里失败了,你或许应该在这里,放一个检查的东西。
Well, the reason, the way that we can check it is just to see if it's in between our two extreme 1 cases. We know that it has to be more than 1, because even if we had total shielding, 1 we would at least feel is the effective of 1.
好的我们可以检查它的原因和方式是观察,它是否在我们的两种极端案例之间,我们知道它必须大于,因为即使如果我们有完全的屏蔽,我们最小感到的有效值是。
It would definitely be wrong if we were doing this because little sanity check if you just got the single one it means what instead?
如果我们这样做就是错误的,一个小检查,如果你用单个“=“,是什么意思?
One of the things that has been interesting with you that I haven't always done in meditation is checking in with various parts of my body, and like really going from head to toe, which is very interesting, just being aware of any aches and pains.
一件让我感兴趣的事,是我在冥想时不经常做的,就是检查身体各处,彻底从头到脚,这一点很有趣,留意各种疼痛。
Every cell in your body has exactly the same DNA; that is if I could stretch out all the DNA and look at the base pair sequence, the sequences of bases along all the DNA in your chromosomes, they'd be identical in all the cells.
身体内每一个细胞都有完全相同的DNA,如果我把整条DNA展开,然后检查其碱基对的顺序,你体内每个细胞中染色体上,DNA的碱基对顺序,都是完全相同的
You know, if you're wandering through Harvard Square and you see an out-of-work Harvard grad, they're handing out examples of square roots, they'll give you an example and you can test it to see is the square root of 2, 1.41529 or whatever.
你知道,如果你从哈佛校园里穿过去,你看见了一个失业校友,正在派发平方根的示例,他们会给你一个例子,而你会检查2的平方根是1。41529或者别的什么。
Let's check it out. I've written a little bit of a test script here, so if we test cell sort, and I've written this so that it's going to print out what the list is at the end of each round, OK.
我们来检查检查,我写了一个小测试脚本,我写这个脚本来测试单元排序,它能够打印出每一轮结束后,链表的是什么样子的。
The second thing I want to highlight is, that what's going on, is that Python is doing some type checking.
我想强调的第二件事情是,这里发生的是,是Python做了一些类型检查的工作。
Oh wait a minute, that's a little different than what we did last time, right?
这同我上次做的有点不同了,是么?,上一次我们检查了输入?
But when you start writing programs, especially when we get to web-based stuff where you want -- to check the user's input -- is it valid, is it an email address, -- and all these different scenarios -- it's actually often useful to be able to just enumerate them or rattle them off using this switching construct instead.
但是当你看是写程序时,特别是当我们,使用基于网络的东西,你想要,检查用户的输入-,它是合法的吗?它是不是一个电子邮箱地址?,所有的这些场景-,实际上它常常是有用的,当你用枚举结构列举它们,或者用它来快速地来说出它们。
It says check to see if I'm in that base case.
这段代码是检查目前是否是最基本的情况。
So again, when we check these, what we want to see is that our z effective falls in between the two extreme cases that we could envision for shielding.
所以当我们再一次检查这些时,我们想看到的是,有效电荷量处于两种极端案例中,这两种极端案例。
If I come into this code, I'm going to check this branch first, if it's not true, ah, there's a return at the end of that branch. If it is true, I do that, and then I've got a second test. If it's true, return I return, otherwise a return.
但是如果我们看看这里,如果我看这段程序,我会先检查这一部分,如果它是假的,啊,这部分分支结尾有一个。
The format is the same. I'm going to ask for some input, and then I am going to use that procedure to check, is this the right type of value. And I'm trying to use that to do the coercion if you like. Same thing if it works, I'm going to skip that, if it not, it's going to throw the exception.
格式是一样的,我需要一些输入,然后我要用一个过程来检查,是否是正确的值,然后你就可以做强制转换了,如果能运行,那是一样的,我打算跳过这段,如果不正确,那就会抛出一个异常。
So that's just a little bit of a check for yourself, and it should make sense because what you're doing is you're calculating the difference between energy levels, so you just need to flip around which you put first to end up with a positive number here, and that's a little bit of a check that you can do what yourself.
所以你们总要确保括号,离得这项是正的,这是你们自己,可以做的检查,这事很有道理的,因为你们做的是计算能量差,所以你需要调整顺序来保证一个正数,这是你们自己可以做的检查。
I probably whip out a do while loop very rarely, but very often when programming games or any program that takes user input and has to check that user input and yell at the user if they're messing with you or aren't providing what's expected.
我可能很少用do,while,循环,但常常是,当编制程序游戏或需要用户输入的程序是,需要检查用户的输入并提醒用户,如果他们干扰了你,或没有提供所期望的输入。
I'm going to give a name to that. And what you see there is I'm going to call divisors initially an empty tuple, something has nothing in it. Right here. And then I'm going to run through the same loop as before, going through this set of things, doing the check.
你们可以看到这里,我初始化一个空的元组,名为divisiors,这里,然后我会去运行,跟以前一样的循环,遍历这个集合内的东西,然后做检查,现在我要做的是,每次我找到了一个除数我要把它收集起来。
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循环。
The reason for pulling this out is, what you're going to see is, that in most languages, all right, Python comes built-in with something that will check your static, sorry, your syntax for you.
讲这些的原因在于,你们将要看到的是,在绝大部分语言中,好的,Python中带着一些,会检查你的static的东西,抱歉,是你的语法。
I test an end test. So the flow chart says, and the tradition was to do this in a diamond shape, I'm going to check if ANS times ANS-- oh, which way did I want to do this x - is less than or equal to x. Now that's a test.
首先进行终结测试,因此流程图就的去,传统的做法是把这个放到一个菱形里面,检查下是否ANS乘以ANS-哦,我刚才是怎么说的来着-是不是小于等于。
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.
就是现在我有了能去检查程序,是不是做了正确的操作的能力:,这就是你们在写每个循环程序的时候,都要注意的两个事情:,第一件事情是要确保程序可以终结,第二件你要做的事情,就是要确保程序返回了正确的答案。
And also I wanted to mention in terms of checking your Lewis structures, regardless of what they are, you should always go back and I had 10, and then count 2, 4, 6, 8, 10, because you always need to make sure you have the same number of valence electrons that you calculated in your actual structure.
我还想提一点关于检查,你的路易斯结构的建议,不管它们是什么,你总是应该回去检查一下,我有十个,然后数一数,二,四,六,八,十个,因为你总是需要确保实际价电子的数量,与你在结构中算出的数量相等。
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的平方不等于?
Now if you look at that list, there is actually something I didn't seem to check, which is, I said I wanted a float stored in hyp.
看下上面的清单,实际上我还有一些东西忘了检查,也就是说hyp中存储的,应该是浮点数类型。
I love Lisp, but Lisp is certainly in the category of a very weakly typed language.
我爱Lisp,但是Lisp当然,是属于在类型检查比较弱的语言一类。
I really do love these things. And is that right, John? OK, so my apologies that your handout is wrong. I did not think to check about the difference between these things.
我真的很喜欢这些东西,这样对不对John?,好,抱歉你们的课堂手册上面是错误的,我没想要要去检查,这些东西之间的不同。
And so if incidentally, you're a representative of a student group and the alike and your Google calendar is not -- in here, you can check just by flipping through the various-- we have over 200 calendars right now and you can search through them here.
如果你是一个学生团体的代表,你的Google日历在此不存在,你可以检查其他各种各样的-,目前我们有200多种日历,你可以在它们之中进行查找。
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的,如果不是的话,请注意会发生什么,下面的代码都不会被执行,程序会到这里来然后显示一些有用的信息,信息会说,嘿,你给了我一个负数,我不知道该怎么弄这个了。
应用推荐