Q.What will be the output of the following statement?
print(14%3**2*4)
(A) 16
(B) 64
(C) 20
(D) 256
print(14%3**2*4)
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →The expression 14%3**2*4 is evaluated using Python's operator precedence: exponentiation first, then modulo and multiplication left to right, giving 20 — option (C).
When evaluating an expression like 14%3**2*4 in Python, the order of operations is decided by operator precedence, which is similar to BODMAS/PEMDAS but tailored to Python's operators.
For the operators here:
**(exponentiation) has the highest precedence.*(multiplication) and%(modulo) share the same, lower precedence.- Operators of equal precedence are evaluated left to right.
Let's break it down step by step.
-
Exponentiation (
**) first.3**2means 3 raised to the power 2, i.e. 3 x 3 = 9. The expression becomes14 % 9 * 4. -
Modulo (
%) and multiplication (*), left to right. Both have equal precedence, so we go left to right. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.