Add only one pair of parenthesis to the following expression so that it produces 0 as the output. 4**2+12%7+4*2-18 You must not add or delete any other operators and/or operands. You must write your answer without any extra spaces between the symbols.
This question is related to the python programming language since the double-asterisk (star) (**)operator is the python's exponential or power operator for computing the mathematical powers of a number raised to a value of a number.
The concept used in this expression value evaluation is the precedence and associativity rules of math operators.
In python, the parenthesis "()" operator has maximum precedence among all operators, and hence it will be computed first of all.
Then, comes the power (**) operator, so it is computed after "()".
Then comes multiplication "*", division "/" and mod "%" operators which are put at the same level of precedence but are computed from the left direction to the right in the expression due to the associativity concept.
Now, in last the add (+) and subtraction (-) operators are also put in the same precedence level but they are computed from the left direction to the right in the expression due to the associativity concept.
By using this concept the answer to this question can be obtained.
Step by step
Solved in 4 steps