ADM-201 dump PMP dumps pdf SSCP exam materials CBAP exam sample questions

【用代数讲计算机科学】操作符运算顺序 – 译学馆
未登录,请登录后再发表信息
最新评论 (0)
播放视频

【用代数讲计算机科学】操作符运算顺序

CS in Algebra: Order of Operations

你可能注意到了求值单元只有两个槽
You may have noticed the evaluation block only has two slots.
那如果我想求1+2+3呢
What if I want to add 1 plus 2 plus 3?
可以把每个槽当做一个输入框
Think of each of these slots as an input.
求值单元的每个输入框能输入一个值 比如1或者2
Each input on an evaluation block can take a value, like 1 or 2.
但也可以嵌入另一个求值单元
But they can also take a whole other evaluation block.
为了计算1+2+3 我们可以再加入一个求值单元 计算2+3
To add 1 plus 2 plus 3, we can drop in an additional block for 2 plus 3.
当电脑计算求值单元时会从内向外计算
When the computer evaluates your blocks, it starts from the inside out, evaluating each
在计算下一级前先计算所有内嵌求值单元
nested block before it moves out to the next level.
这就给我们提出了所谓“操作符顺序”的概念
This brings us to the order of operations.
操作符是一系列动作 例如加减乘除
Operations are actions, such as add, subtract, multiply and divide.
不是数字 就可能是操作符
If it isn’t a number, it probably is an operation.
但当你计算7+(6×52+3) 时
But when you see something like 7 plus 6 times 52 plus 3,
应该先算哪一部分呢?
which part should you calculate first?
你是从左算到右的吗
Do you start at the left and go to the right?
或是从右到左
Or start at the right and go to the left?
这实际上有很大的问题 因为以错误的顺序计算会得到错误的答案
This actually matters because calculating in the wrong order will get you a wrong answer.
专门的操作符顺序会告诉你先做什么后做什么
There is a specific order of operations
什么先做什么后做
that tells you what to do first and then to do next.
我们能用一个酷炫的单词:PEMDAS来记忆这一法则
We can remember the order with a cool word called PEMDAS:
括号 指数 乘法 除法 加法 和减法
Parentheses, Exponents, Multiplication, Division, Addition and Subtraction.
先计算括号中内容: 6×(5+3)转化为6×8 等于48
Do things in parentheses first: 6 times 5 plus 3 turns into 6 times 8 which equals 48.
如果我们只是从左算到右 6×5就是30 再加3
If we just went left to right and did 6 times 5 and got 30 and then added 3, that would
等于33 这是错误的
equal 33 which is wrong.
算完括号里的 接下来算指数
After we’ve done parentheses, we move on to exponents.
例如 我们先算2的平方 然后再乘5 得20
In this example, we square the 2 first and then multiply it by 5 to get 20.
接下来是M和D 乘法和除法
Next is M and D for multiply and divide.
在你的算式中 任何地方的乘除都优于加减 先
Anywhere in your expression that has a multiply or divide sign needs to be done before addition
计算
or subtraction.
如果一个算式中同时存在乘除 只要从左算到右即可
If there is multiply and divide in the same expression, then just go left to right.
再说一遍 PEMDAS代表:P-括号先计算 E-指数其次 然后是M,D-乘除
Again, PEMDAS stands for: P – Parentheses first, E – Exponents next, then M, D – Multiplication
从左算至右 最后是A,S-加减
and Division which is done left to right and finally A, S – for Addition and Subtraction
也是从左算到右
which is also done left to right.
乘除为同一级 从左算到右
Divide and Multiply rank equally and go left to right.
加减也为同一级 也是从左算到右
Add and subtract rank equally as well and go left to right.
你可以以一些有趣的短语来记PEMDASA 比如请原谅 我亲爱的姑妈或者
You can remember PEMDAS with a few fun phrases like Please Excuse My Dear Aunt Sally or Pudgy
矮胖的孩子可能需要一些零食 甚至是请食用妈妈的美味的苹果派
Elves May Demand A Snack or even Please Eat Mom’s Delicious Apple Strudels.
你的电脑并没有智能到可以理解运算规则
Your computer isn’t smart enough to understand order of operations.
你需要把它以你想要的运算顺序书写
You need to show it the order you want operations to be done in.
我们能够用嵌套在其他单元框中的嵌套单元框来实现
We can do that by nesting blocks inside of other blocks.
单元框是从左到右 自内而外的计算的
Blocks are evaluated from left to right and from the inside out.
如果我们想编写计算8-2×5+10÷2+1
If we wanted to program the expression 8 minus 2 times 5 plus 10 divided by 2 plus 1, we
我们能够使用PEMDAS来记忆我们应该嵌套单元框的顺序
can use PEMDAS to remember the order we should nest our blocks in.
P-这里并没有圆括号 所以略过
P – there are no parentheses so let’s move on.
E-也没有指数
E – no exponents either.
接下来是乘法-E 有的 因此我们做乘法运算
Next Multiplication – M. Ok, so we have some multiplication.
来做一个2×5的单元框
Let’s make a block for the 2 times 5.
D-这里也有除法
D – there’s also some division too.
做一个10÷2的单元框
Let’s make a block for 10 divided by 2.
AS-这里也有加法和减法 因此我们从左到右挑出它
A, S – we’ve also got addition and subtraction here so let’s sort it out from left to right.
首先我们可以攫取一个减法单元框 再在左边输入8 右边输入
First we can grab a subtraction block and plug in 8 on the left and our 2 times 5 block
2×5的单元框
on the right.
接着我们设置一个加法单元框 将8-2×5单元框放在左边
Then we’ll grab an addition block, plug in our whole 8 minus 2 times 5 expression on
另一个加法单元框放在右边
the left and another addition block on the right.
最后 我们在左边输入10÷2 在右边输入1
Then finally we can plug in our 10 divided by 2 on the left side and 1 on the right.
8-2×5+10÷2+1
8 minus 2 times 5 plus 10 divided by 2 plus 1.
就这样
And that’s it!
求值单元版本的数学表达式
The block version of this mathematical expression.

发表评论

译制信息
视频概述

求值单元下的操作符运算顺序 如何实现数学表达式的转换

听录译者

收集自网络

翻译译者

谨之的猫

审核员

知易行难

视频来源

https://www.youtube.com/watch?v=ycgedpCoIr4

相关推荐