And then, when I got- I'm also going to count how many comparisons I do, just so I can see how much work I do here, and then notice what it does.
并能看到算法干了些什么-,然后是如果这个索引,比数组的大小小的话,就意味着还没检索到数组的最后。
I'm gonna zoom in a little more and notice it's pretty much 1, 2, 3, 4, 5, 6, 7, 8, 9 lines of code and that's kind of rounding up because of the white space.
我现在放大一点,大家会看到,2,3,4,5,6,7,8,9行代码,多亏了空格,这些代码才能看起来如此美观。
self y Notice what I also do here, I create self dot y, give it a value, and then, oh cool, I can also set up what's the radius and angle for this point, by just doing a little bit of work.
我创建了,然后给它赋值,然后,噢太酷了,通过做一点额外的工作,就可以得到点的半径和角度了,好,实际上如果。
It means that if I took this cell and isolated and watched it, I'd notice that it had a couple of characteristics.
意思就是如果我取这些细胞,分离并观察,我会发现它有几个特征
It's not that hard, and in particular, notice that all I'm doing here is writing down notation.
这没有你想象的那么难,我只不过写下了一些符号
And then notice the structure, WHILE I got a keyword WHILE, there's that color identifying it, and in parentheses I have a test.
然后注意这个结构,有一个关键词,颜色就可以区分出它了,然后括号内是个测试。
And notice, by the way, when I typed it how print showed up in a different color?
注意,顺便说一下,当我输入的时候,怎样才能显示不同的颜色呢?
See if we can find it here. And notice, by the way, that I commented out the previous debugging line, rather than got rid of it.
我们再去从它们的中间开始尝试,看看我们能不能发现问题源,顺便说一下,请注意。
And you might say, wait a minute, isn't that a string, and the answer's no, I didn't say it's a string by putting quotes around it And notice how the machine responds differently to it.
你会想,等等,这不是个字符串么?,答案是否定的,我没用引号包围它就意味着它不是字符串,请注意计算机对它给出了不同的反应。
Well I need to take that number and I'm going to turn it into a string. So notice what I'm going to do right here. I take that number and convert it into a string. That's an example of that type conversion we did earlier on. By doing that it makes it possible for me to treat it as an ordered sequence of characters.
我可能得把这个数字变为字符串,请注意我这里是怎么做的,我把这个数字,转化为字符串了,这是我们之前学过的,类型转换的例子,这么一来我就能把它按照有序的。
Yeah, I've still got a binding for z and I'm giving it the same test, but notice now I've got the two same commands but they have different indentation.
对,我还是对z进行了绑定,我还是要对它进行同样的测试,但是请注意现在我有了两个同样的命令,但是它们有不同的缩进。
You'll notice I have the string with the number 1 MIT a string with MIT, and then it just a plain old number, not a string, again it didn't quite give me 3.3 for reasons we've talked before, a and now it in the list a.
你们可以看到这儿有个以字符串1,形式显示的数字1,1个字符串,还有一个非字符串形式的平常数字,结果并不是3。3,原因之前我们,已经讨论过了,还有一个在list中的。
So I can concatenate techs plus ivys and assign that result to univs, and then when I print it you'll notice I just get a list of five strings.
和ivys数组用加号串联运算,并把结果赋值给univs数组,接下来我显示下univs的结果,你注意到我得到了一个。
If it isn't, then I'm going to go back around the loop, and notice what happens. If I get all the way around the loop, that is, all the way through that FOR loop and I never find a path that takes me through here, then the last thing I'm going to do is return a pair or a tuple with a special simple number none twice.
如果没有,我会回到循环看看发生了什么,如果我运行了整个循环,也就是整个for循环,我仍没有找到符合条件的路径,那么我最后做的事情就是返回一对,或者一个数组的两次none值。
应用推荐