Bird
0
0

What is the output of the following code?

medium📝 Predict Output Q13 of 15
Python - Operators and Expression Evaluation
What is the output of the following code?
result = 10 - 3 * 2 + 4 // 2
print(result)
A5
B8
C6
D4
Step-by-Step Solution
Solution:
  1. Step 1: Apply operator precedence and evaluate multiplication and floor division first

    3 * 2 = 6
    4 // 2 = 2
  2. Step 2: Evaluate the expression left to right with addition and subtraction

    10 - 6 + 2 = 4 + 2 = 6
  3. Final Answer:

    6 -> Option C
  4. Quick Check:

    10 - 6 + 2 = 6 [OK]
Quick Trick: Multiply and divide before add and subtract [OK]
Common Mistakes:
MISTAKES
  • Adding before multiplying
  • Using normal division instead of floor division
  • Ignoring left to right evaluation for same precedence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes