Same way that I have multiplication or division as a primitive, functions are going to give me, or somebody else who wrote them for me as part of a library, a new primitive that I'm going to be able to use.
我在用乘法或者除法当做原语,这些函数,或者别人写程序库中的函数,将会给我返回一个,我能使用的新原语。
I've got one test there, and then I've just got one thing to do here, which has got a subtraction and a multiplication.
这儿有一个比较,然后在一个基本步骤里,做了一个减法和一个乘法两个基本操作。
It's really the multiplication and in this case, division that the problem arises. Yeah?
这里实际上是乘法和,除法引起了那个问题,请说?
One of the first principles of probability theory is called the multiplication rule.
概率论的最基本的原则,有一条叫乘法原理
For example, you're not doing your multiplication tables.
比如说,你并没有在做乘法。
But what I do? I just separated, do I do the addition first or do the multiplication first?
那么我该怎么办?我就是要做一个分割,应该先做加法呢,是先做乘法呢?
You might recall from grade school sometimes you put things in parentheses so that your addition happens first, then your multiplication, otherwise multiplication would happen by default first.
你们可能会想起小学时,将一些加法表达式,放在圆括号里,这样加法可以先计算,然后是乘法,否则,乘法默认先发生。
Just as in grade school when you're doing division and multiplication, you do it from left to right in terms of order of operations.
正像是在小学你做除法和乘法的时候,你毫不含糊地从左到右,按顺序做运算。
And I'm going to do it only using multiplication and addition and some simple tests. All right?
我只能用乘法和加法,以及一些小测试来解决这个问题?
STUDENT: Standard order of operations, I guess take the multiplication first, and add the three.
学生:标准运算符的顺序,我猜是先做乘法,然后再去加3。
Because this is overloading that multiplication operator with two different tasks.
因为这会造成使得乘法操作符,对两种不同的任务造成重载。
Things like addition and multiplication, which we saw not only apply to numbers, but we can use them on things like strings and we're going to come back to them again.
就像加法和乘法,我们已经学习过,它们不仅仅可以应用于数字,还可以用到字符串上,我们今天还会再讲讲。
And so, in fact, if I wanted the other version of it, in fact, if I do this right, 23 it's going to give me 23 because it does the multiplication first, if I wanted the other version of it, Python I need to tell it that, by using, excuse me, parentheses.
因此,实际上,如果我想换种做法,实际上,如果我去执行这个表达式,返回值是3,因为乘法会被优先执行,如果我需要换种做法,我需要告诉,用括号来告诉它。
They're inside that loop-I've got the wrong glasses so I'm going to have to squint- and we've got one test which is a comparison we've got another test which is a multiplication-- sorry, not a test, we've got - another step which is a multiplication- and another step that is a subtraction.
他们在循环里面呢,我带错眼镜了所以不得不斜视-,然后我们这里有一个比较的测试,还有一个乘法的测试,-对不起,不是测试,是另外一个乘法的步骤-,还有一个减法的步骤。
You still could do your multiplication tables.
你还是能够做乘法的。
I've got one test, I've got a subtraction, I've got a multiplication, that's three steps, plus whatever number of steps it takes to solve a problem of size b minus 1.
我进行了一次比较,一次减法,一次乘法,一共是三个步骤,再加上t的步骤数。
应用推荐