Q.What will the following expression be evaluated to in Python? print(4+3*5/3-5%2)
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 →Python evaluates 4 + 3 * 5 / 3 - 5 % 2 using operator precedence: *, /, % first (left to right), then +, - (left to right). The result is 8.0, so the answer is (b).
When Python evaluates an arithmetic expression it does not simply read left to right — it follows operator precedence (which operations happen first) and associativity (the order among operators of equal precedence). This is the same BODMAS/PEMDAS idea from mathematics.
The operators here rank as follows:
| Operator | Meaning | Precedence | Associativity |
|---|---|---|---|
* | Multiplication | Higher | Left to right |
/ | Division | Higher | Left to right |
% | Modulo (remainder) | Higher | Left to right |
+ | Addition | Lower | Left to right |
- | Subtraction | Lower | Left to right |
*, / and % share the same (higher) precedence, so they run left to right first; then + and - run left to right.
Step by step for 4 + 3 * 5 / 3 - 5 % 2:
3 * 5=15→4 + 15 / 3 - 5 % 2…
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.