PEMDAS

Execute these two instructions in the Repl.it command line window:

8**(1/3)
8**1/3

You should recognize the first instruction from the previous section. Observe that these instructions yield two totally different answers. The reason is that there is an order in which operators are evaluated. The "order of operations" and "operator precedence" define how arithmetic calculations are to be evaluated. As expected from basic arithmetic, exponentiation takes place before multiplication and division which take place before addition and subtraction. In addition, operations are generally read from left to right.

As an example, consider the expression 8**1/3 as shown above. In this case, exponentiation taking precedence over division means that 8**1 is computed first to obtain a value of 8 and then that result is divided by 3. Hence, the final computed result is 8/3 = 2.6666...67. Notice that, when parentheses are added around the exponent to form 8**(1/3), the exponent evaluates to 1/3 and the cube root of 8 is computed. The term inside the parentheses has higher precedence and takes place before exponentiating. This should be a refresher about the order arithmetic expressions are evaluated in.

Last modified: Tuesday, November 17, 2020, 5:00 PM