Question 2
The following Python expression is entered into a fresh Python shell with no prior import statements. Determine the result from evaluating the following expression. [3 marks]
Solution
Since the division / and * operators have a higher precedence level than the addition + operator, we compute using those operations from left to right first before addressing the + operation.
Note
The answer does not equate to simply 63, but 63.0.
This is because when using the regular divison / operator, the end result turns into a floating-point value.
From here, that value type sticks around for the two operations following that.
However, if the question asks for 3 + 20 // 4 * 12, which involves the integer divison // operator, then we can compute the result as just 63 as an integer value.