Bird
0
0

Given the following inventory update code snippet, what will be the final quantity of 'banana'?

medium📝 Analysis Q4 of 15
LLD - Design — Online Shopping Cart
Given the following inventory update code snippet, what will be the final quantity of 'banana'?
inventory = {'apple': 10, 'banana': 5}
inventory['banana'] += 3
inventory['apple'] -= 2
A8
B3
C5
D10
Step-by-Step Solution
Solution:
  1. Step 1: Analyze initial inventory values

    Banana starts with quantity 5.
  2. Step 2: Apply the update operation

    Banana quantity is increased by 3, so 5 + 3 = 8.
  3. Final Answer:

    8 -> Option A
  4. Quick Check:

    Banana quantity after update = 8 [OK]
Quick Trick: Add increments to initial quantity for final count [OK]
Common Mistakes:
  • Subtracting instead of adding
  • Confusing apple's update with banana's

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes