Solved 2024 Sample Question Paper CBSE Class 12 Computer Science (083) — Question 3
Back to all questions-244.0
Reason — In Python, both ** (exponentiation) and / (division) operators have the same level of precedence, which means they are evaluated from left to right if they appear together without parentheses. However, the exponentiation operator ** is right-associative, which means it is evaluated from right to left. In the given expression print(3 - 2 ** 2 ** 3 + 99 / 11), the innermost exponentiation (2 ** 3) is evaluated first, followed by the outer exponentiation (2 ** 8). Then subtracting the result of the exponentiation from 3, 3 − 256 = −253, then adding the result of the division ((99/11) = 9) to the previously calculated value −253 + 9 = −244.0. The expression is evaluated as follows:
3 - 2 ** 2 ** 3 + 99 / 11
= 3 - 2 ** 8 + 99 / 11
= 3 - 256 + 99 / 11
= 3 - 256 + 9.0
= -253 + 9.0
= -244.0